895
895
----
896
896
``` python
897
897
import json
898
- < str > = json.dumps(< object > , ensure_ascii = True , indent = None )
899
- < dict > = json.loads(< str > )
898
+ < str > = json.dumps(< object > , ensure_ascii = True , indent = None )
899
+ < object > = json.loads(< str > )
900
900
```
901
901
902
902
#### To preserve order:
@@ -920,6 +920,29 @@ def write_to_json_file(filename, an_object):
920
920
```
921
921
922
922
923
+ Pickle
924
+ ------
925
+ ``` python
926
+ import pickle
927
+ < bytes > = pickle.dumps(< object > )
928
+ < object > = pickle.loads(< bytes > )
929
+ ```
930
+
931
+ ### Read Object from File
932
+ ``` python
933
+ def read_pickle_file (filename ):
934
+ with open (filename, ' rb' ) as file :
935
+ return pickle.load(file )
936
+ ```
937
+
938
+ ### Write Object to File
939
+ ``` python
940
+ def write_to_pickle_file (filename , an_object ):
941
+ with open (filename, ' wb' ) as file :
942
+ pickle.dump(an_object, file )
943
+ ```
944
+
945
+
923
946
SQLite
924
947
------
925
948
``` python
@@ -944,29 +967,6 @@ db.commit()
944
967
```
945
968
946
969
947
- Pickle
948
- ------
949
- ``` python
950
- import pickle
951
- < bytes > = pickle.dumps(< object > )
952
- < object > = pickle.loads(< bytes > )
953
- ```
954
-
955
- ### Read Object from File
956
- ``` python
957
- def read_pickle_file (filename ):
958
- with open (filename, ' rb' ) as file :
959
- return pickle.load(file )
960
- ```
961
-
962
- ### Write Object to File
963
- ``` python
964
- def write_to_pickle_file (filename , an_object ):
965
- with open (filename, ' wb' ) as file :
966
- pickle.dump(an_object, file )
967
- ```
968
-
969
-
970
970
Exceptions
971
971
----------
972
972
``` python
0 commit comments