當前位置:首頁 » 編程語言 » python取變數名

python取變數名

發布時間: 2025-06-24 00:39:01

A. 請教python如何得到一個變數的名字

python獲得一個變數的名字的方法:
正常人:
items={
'tom':[1,2,3],
'jack':[4,5,6],
'alice':[7,8,9]
}
for x in items:
print "id of %s is %d" %(x,id(x))
變態:
tom = [1,2,3]
jack = [4,5,6]
alice = [7,8,9]
items = tom, jack, alice
for item in items:
for itemx,itemy in locals().items():
if item == itemy and itemx != 'item':
print itemx

熱點內容
java返回this 發布:2025-10-20 08:28:16 瀏覽:593
製作腳本網站 發布:2025-10-20 08:17:34 瀏覽:888
python中的init方法 發布:2025-10-20 08:17:33 瀏覽:581
圖案密碼什麼意思 發布:2025-10-20 08:16:56 瀏覽:765
怎麼清理微信視頻緩存 發布:2025-10-20 08:12:37 瀏覽:684
c語言編譯器怎麼看執行過程 發布:2025-10-20 08:00:32 瀏覽:1013
郵箱如何填寫發信伺服器 發布:2025-10-20 07:45:27 瀏覽:255
shell腳本入門案例 發布:2025-10-20 07:44:45 瀏覽:114
怎麼上傳照片瀏覽上傳 發布:2025-10-20 07:44:03 瀏覽:806
python股票數據獲取 發布:2025-10-20 07:39:44 瀏覽:712