def readpickle(filename='gradesdict.p'):
import pickle # import module first
f = open(filename, 'rb') # 'r'/ 'rb' for reading; can be omitted
variable = pickle.load(f) # load file content
f.close()
return variable
def writepickle(variable, filename='gradesdict.p'):
import pickle # import module first
# f = open('gradesdict.p', 'w') # 'w'/'wb' Pickle file is newly created where foo1.py is
f = open(filename, 'wb')
pickle.dump(variable, f) # dump data to f
f.close()
return