read contents of a file python code example
Example 1: how to get the contents of a txt file in python
path= #path here
with open(path) as file
contents = file.read()
Example 2: how to write a python variable to a file
#use pickle
import pickle
dict = {'one': 1, 'two': 2}
file = open('dump.txt', 'w')
pickle.dump(dict, file)
file.close()
#and to read it again
file = open('dump.txt', 'r')
dict = pickle.load(file)