Discuss / Python / 不知道为什么报错,换成pickle就可以了

不知道为什么报错,换成pickle就可以了

Topic source

zL丶_44830

#1 Created at ... [Delete] [Delete and Lock User]

import json dic={dict(name='bobe',age=16,score=88)} f=open('dummy.txt','wb') json.dump(dic,f) f.close() f=open('dummy.txt','rb') t=json.load(f) print(t)

json.dump(dic,f) 这一句报错

zL丶_44830

#2 Created at ... [Delete] [Delete and Lock User]

import json dic=dict(name='bobe',age=16,score=88) f=open('dummy.txt','wb') json.dump(dic,f) f.close() f=open('dummy.txt','rb') t=json.load(f) print(t)

上面代码贴错了

zL丶_44830

#3 Created at ... [Delete] [Delete and Lock User]

好吧,我发现了,没仔细看。。。尴尬


  • 1

Reply