Skip to content

Commit 46ea5e5

Browse files
committed
Json, pickle
1 parent d578c45 commit 46ea5e5

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

README.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -895,8 +895,8 @@ JSON
895895
----
896896
```python
897897
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>)
900900
```
901901

902902
#### To preserve order:
@@ -920,6 +920,29 @@ def write_to_json_file(filename, an_object):
920920
```
921921

922922

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+
923946
SQLite
924947
------
925948
```python
@@ -944,29 +967,6 @@ db.commit()
944967
```
945968

946969

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-
970970
Exceptions
971971
----------
972972
```python

0 commit comments

Comments
 (0)