将文件的每行读取到字典中
文件每行内容格式为:
cui:123456789
f = open(‘user.txt‘) d = f.readlines() f.close() mydict = {} for i in d: user = i.split(‘:‘)[0] info = i.split(‘:‘)[1].rstrip() mydict[user] = info
2023-11-28 17:16:22
将文件的每行读取到字典中
文件每行内容格式为:
cui:123456789
f = open(‘user.txt‘) d = f.readlines() f.close() mydict = {} for i in d: user = i.split(‘:‘)[0] info = i.split(‘:‘)[1].rstrip() mydict[user] = info