json反序列化

#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author:Random_lee

# import json
#
# f=open('test.text','r')
#
# data=json.loads(f.read())
# print(data['age'])
import pickle
def sayhai(name):
print('hello',name)
print('hello2',name)

f=open('test.text','br')
data=pickle.loads(f.read())
print(data['func']('randomelee'))



#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author:Random_lee
import pickle
def sayhai(name):
print('hello',name)
f=open('test1.text','rb')
data=pickle.load(f) #data=pickle.loads(f.read())
print(data['age'])

#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author:Random_lee
# import pickle
import json

# def sayhai(name):
# print('hello',name)

f=open('test3.text','r')
data=json.loads(f.read())
print(data['age'])

posted @ 2018-04-01 12:12  random_lee  阅读(190)  评论(0编辑  收藏  举报