Python3 Jason & Pickle

Source: Internet
Author: User

#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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.