我是Python的初学者,因此不确定为什么会收到以下错误:
TypeError: invalid file: []
对于这行代码:
usernamelist=open(user_names,'w')
我正在尝试输入用户名和密码,将它们写入文件,然后读取它们。在
下面是我剩下的代码:
user_names=[]
passwords=[]
username=input('Please enter a username')
password=input('Please enter a password')
usernamelist=open(user_names,'w')
pickle.dump(userName,usernamelist)
usernamelist.close()
usernamelist=open(user_names,'r')
loadusernames=pickle.load(usernamelist)
passwordlist=open(passwords,'w')
pickle.dump(password,passwordlist)
passwordlist.close()
passwordlist=open(passwords,'r')
loadpasswords=pickle.load(passwordlist)
所有答案将不胜感激。谢谢。在
根据你的脚本,这可能会有所帮助。它创造了一个'用户名.txt'和'密码.txt'存储输入用户名和密码。在
我使用python2.7,输入在python2.7和python3.x中的行为不同
相关问题 更多 >
编程相关推荐