try:
with open('man_data.txt','rb') as man_file:
man=pickle.load(man_file)
except IOError as err:
print('File error:'+str(err))
except pickle.PickleError as perr:
print('Pickling error:'+str(perr))
错误:
Traceback (most recent call last):
File "E:\05.程序\py\66666.py", line 30, in <module>
man=pickle.load(man_file)
ValueError: could not convert string to int
nester没有用到的(后面用),不关事。。。。
...全文
12717打赏收藏
could not convert string to int
试过好多次。。。网上说什么正则表达式的。。。然后缩进什么的。。。 import pickle import nester new_man=[] try: with open('man_data.txt','rb') as man_file: man=pickle.load(man_file) except IOError as err: print('File error:'+str(err)) except pickle.PickleError as perr: print('Pickling
['Is this the right room for an argument?', "No you haven't!", 'When?', "No you didn't!", 'You most certainly did not!', '(exasperated)Oh,this is futile!!', 'Yes it is!']
时为
Pickling error:invalid load key, '['.
而当txt内容为:
Is this the right room for an argument?
No you haven't!
When?
No you didn't!
You most certainly did not!
(exasperated)Oh,this is futile!!
Yes it is!
就出现:
ValueError: could not convert string to int
head first python这本书没有说这个txt格式是原始还是怎么样的。。。当当运行了前面的程序,分成一行一行后就这样了。。。
请问如何修改txt才能运行?还是说用pickle时,txt内容有规定?