json.dumps和loads方法
DUMPS
import json
# xuxu = {'name':'xuxu','age':'25'}
# xuxu1 = json.dumps(xuxu)
# f = open('JSON_test','w')
# f.write(xuxu1)
# f.closed
def foo():
print('foo')
xuxu1 = json.dumps(foo)#不可以报错
# f = open('JSON_test','w')
# f.write(xuxu1)
# f.closed
LOADS
import json
f = open('JSON_test','r')
data = f.read()
data = json.loads(data)
print(data['name'])