#Author by Andy
#_ *_ Coding:utf-8 _*_
Import JSON
Import Pickle
def sayhello (name):
Print (' Hello%s '%name)
Return ' Hello%s '%name
info={
' Name ': ' Andy ',
' Age ': 20,
' Job ': ' Doctor ',
}
info1={
' Name ': ' Andy ',
' Age ': 20,
' Job ': ' Doctor ',
' Func ': SayHello
}
# print (type (info))
F=open (' E:\my python Study\\files\json & Pickle.txt ', ' RB ')
# Json.dumps (Info) #将字典转为字符串 (serialized)
# json.dump (info,f) #=f.write (Json.dumps (info))
# json.load (f)) #=json.loads (F.read ())
# Json.loads ((Json.dumps (info))) #将字符串转为字典
#Json主要用于不通语言之间的数据交互, supports dictionaries, lists, strings, tuples, collections
# p=pickle.dumps (INFO1) #将字典转为二进制
# Pickle.dump (info1,f)
#一个文件只能dump一次, Load once
# Print (Pickle.loads (p)) #将二进制转为字典
def sayhello (name):
Print (' Hello%s '%name)
Return ' Hello%s '%name
Print (Pickle.load (f) [' func '])
Python3 Jason & Pickle