In my python program, I have a list of keys and values that are added to a text file and I need to be able to extract this string list and turn it into a dictionary.
For example:
counter = 0
add = str(counter)
counterDict = UserID + ": " + add + ", "
counter = counter + 1
#This should make counterDict look like: ""Smi39119": 0, "Joh38719": 1, " etc.
f = open("Dictionaries.txt","a")
f.write(counterDict)
f.close()
#Then I would like to be able to open the file and turn that string into a dictionary
f = open("Dictionaries.txt","r")
string = f.read()
#This way 'string' should still be a string, but look like this: "{"Smi39119": 0, "Joh38719": 1, }"
I do not know if this is possible, but if it is, all solutions would be greatly appreciated.