Name the Python module need to be imported to invoke the function? load()
2023
Name the Python module need to be imported to invoke the function? load()
- A.
csv
- B.
pickle
- C.
sql
- D.
binary
Attempted by 2020 students.
Show answer & explanation
Correct answer: B
Answer: pickle Reason: The load() function is provided by the pickle module and is used to deserialize (read) Python objects from a binary file. Import the module: import pickle
Open the file in binary read mode: with open('file.pkl', 'rb') as f:
Deserialize the object: obj = pickle.load(f)
Note: pickle.load expects a file opened in binary mode ('rb'). Using text mode will raise an error or produce incorrect results.