PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import pickle
# Sample data (list of dictionaries)
people_data = [
{'name': 'pavan', 'age': 18, 'city': 'asifabad'},
{'name': 'Bapu', 'age': 20, 'city': 'utnoor'},
{'name': 'chinnu', 'age': 25, 'city': 'jainoor'}
]
# Serialize the data to a binary string
serialized_data = pickle.dumps(people_data)
# Save the serialized data to a file
with open('serialized_people.pkl', 'wb') as file:
file.write(serialized_data)
# Read the serialized data from the file
with open('serialized_people.pkl', 'rb') as file:
# Deserialize the data back into a Python object
loaded_data = pickle.load(file)
# Display the loaded data
print("Loaded Data:", loaded_data)
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run