我尝试使用pickle从二进制文件中读取,调整其内容,然后用新的更新字典覆盖二进制文件的内容。 但是,我收到以下错误:
startHandCountFile = open("startHandCount", 'wb') OSError: [Errno 22] Invalid argument: 'startHandCount'.
我目前的理解是,它应该可以工作,因为文件与正在运行的python文件位于同一个目录中,并且我已经检查了我没有错过拼写该文件。在
我的代码:
startHandCountFile = open("startHandCount", "rb")
self.startHandCount = pickle.load(startHandCountFile)
self.currentStartHandCount = self.startHandCount
self.startHandCount[startingTotal][1] += 1
print("print still working")
startHandCountFile.close()
startHandCountFile = open("startHandCount", 'wb')
pickle.dump(self.currentStartHandCount, startHandCountFile)
startHandCountFile.close()
谢谢你的帮助。在
尝试运行我的程序在我的dropbox外,在硬盘上的一个目录中运行,解决了我遇到的错误。在
相关问题 更多 >
编程相关推荐