程序运行不了
一个文件类容的改动
dict1={}
num=input("省份证件号:")
name=input("姓名:")
num2=input("房间号:")
num3=input("房费:")
num4=input("押金:")
A=open("信息表.text","a")
A.write(num+","+name+","+num2+","+num3+","+num4+","+"\n")
A.close()
B=open("信息表.text","r")
for eachline in B:
dict1]=eachline
print(eachline)
print("1:查询住户信息2:修改住户信息 3:添加住户 4:删除住户")
B.close()
Ch=input("请选择:")
if Ch==1:
Ch1=input("请输入身份证件号:")
print(dict1)
elif Ch==2:
Ch1=input("请输入身份证件号:")
print(dict1)
R=open("信息表.text","w")
dict=input("请按照顺序填写信息:")
for k,v in dict1:
R.write(k+","+v)
R.close()
elif Ch==3:
D=open("信息表.text","a")
num=input("省份证件号:")
name=input("姓名:")
num2=input("房间号:")
num3=input("房费:")
num4=input("押金:")
D.write(num+","+name+","+num2+","+num3+","+num4+","+"\n")
D.close()
else:
E=open("信息表.text","w")
Ch1=input("请输入身份证件号:")
dict1.pop(Ch1)
for k,v in dict1 :
E.write(k+","+v)
E.close()
显错
ValueError: too many values to unpack (expected 2)
试试这样:dict1={}
num=input("省份证件号:")
name=input("姓名:")
num2=input("房间号:")
num3=input("房费:")
num4=input("押金:")
A=open("信息表.text","a")
A.write(num+","+name+","+num2+","+num3+","+num4+","+"\n")
A.close()
B=open("信息表.text","r")
for eachline in B:
dict1]=eachline
print(eachline)
print("1:查询住户信息2:修改住户信息 3:添加住户 4:删除住户")
B.close()
Ch=input("请选择:")
if Ch==1:
Ch1=input("请输入身份证件号:")
print(dict1)
elif Ch==2:
Ch1=input("请输入身份证件号:")
print(dict1)
R=open("信息表.text","w")
dict=input("请按照顺序填写信息:")
for k,v in dict1.items():
R.write(k+","+v)
R.close()
elif Ch==3:
D=open("信息表.text","a")
num=input("省份证件号:")
name=input("姓名:")
num2=input("房间号:")
num3=input("房费:")
num4=input("押金:")
D.write(num+","+name+","+num2+","+num3+","+num4+","+"\n")
D.close()
else:
E=open("信息表.text","w")
Ch1=input("请输入身份证件号:")
dict1.pop(Ch1)
for k,v in dict1.items() :
E.write(k+","+v)
E.close() ValueError: too many values to unpack (expected 2)
解压值错误,得到了超过预期的2个解压值。
应该还有提示你哪一行错了,看是不是给多值了。
页:
[1]