看世界
 
昨日:篇  今日:篇   总帖:篇   会员:
admin
创始人Lv1   
遍历dict     
txtpath="D:\\down\\loupan\\chengdu\\1010.txt"
dict_data = {}
with open(txtpath, 'r') as f:
    for kv in [d.strip().split(':') for d in f]:
        dict_data[kv[0]] = kv[1]
# print(dict_data)

for (k,v) in dict_data.items():
    print k
    print v

 0  已被阅读了6次  楼主 2018-10-10 22:40:14
回复列表

回复:遍历dict

LOOK官方站 联系站长
Powered by Look博客