我正在使用python3.3,并且在尝试腌制一个简单的字典时遇到一个神秘的错误。这是代码:import osimport picklefrom pickle import *os.chdir('c:/Python26/progfiles/')def storvars(vdict): f = open('varstor.txt','w') pickle.dump(vdict,f,) f.close() returnmydict = {'name':'john','gender':'male','age':'45'}storvars(mydict)我得到:Traceback (most recent call last): File "C:/Python26/test18.py", line 31, in <module> storvars(mydict) File "C:/Python26/test18.py", line 14, in storvars pickle.dump(vdict,f,)TypeError: must be str, not bytes
添加回答
举报
0/150
提交
取消