【发布时间】:2020-05-06 08:48:41
【问题描述】:
我尝试使用以下代码将文本文件转换为字典:
d = {}
with open('staff.txt', 'r') as file:
for line in file:
(key, val) = line.split()
d[str(key)] = val
print(d)
staff.txt 文件中的内容:
username1 jaynwauche
password1 juniornwauche123
e_mail1 juniornwauche@gmail.com
Fullname1 Junior Nwauche
错误:要解压的值太多 我做错了什么?
【问题讨论】:
-
错误:要解压的值太多:您从错误消息中看不懂什么?
标签: python string dictionary