I have the following file dic.txt:
{'a':0, 'b':0, 'c':0, 'd':0}
I want to read its contents and use as a dictionary. After entering new data values I need to write them into that file. Basically I need a script to work with the dictionary, update its values and save them for later use.
I have a working script, but can't figure out how to actually read the contents of the dic.txt into a variable in the script. Cause when I try this:
file = '/home/me/dic.txt'
dic_list = open(file, 'r')
mydic = dic_list
dic_list.close()
What I get as mydic is a str. And I can't manipulate its values. So here is the question. How do I create a dictionary from a dic.txt?