Json
- Conversions between data types for strings and Python
- Four functions
Pickle
- Conversion for Python-specific types and Python data types
- Four functions
Shelve
- K,v is a simple module that persists memory data through a file, and can persist any Python data format that pickle can support
1 #!/user/bin/python2 #-*-coding:utf-8-*-3 Importshelve4 5D = Shelve.open ('shelve_test')#Open the current script (the name in Open is the name of the current script)6 7 #info = {' age ': ' Job ': ' It '}8 #9 #name=[' Alex ', ' rain ', ' Test ']Ten #d[' name ' = name # The persistence list generates a file in the current directory that stores the information in the name. One #d[' info ' = info # persistence dictionary, generates a file in the current directory to store information in info. A #altogether three files were generated, shelve_test.bak; slelve_test.dat; shelve_test.dir. - - the #The contents of the name and info can be obtained by reading the contents of the generated file. - Print(D.get ('name')) - Print(D.get ('Info'))
Python JSON & Pickle, shelve module