Completely frustrating - I have been googling for a solution for this for a couple of hours now. I have this little bit of code that I wish to read a text file into a Python Dictionary. I used this dictionary format internally within the another piece of code I am writing and had no problems. But trying to import it from an external text file I get a syntax error
It doesn't like : or < > I suspect it is to do with the unicode. I have even removed all the illegal characters but it didn't like that either. I even place a u in front of "word.txt" with no success.
Can someone please explain what is the right syntax for the creation of a string in a text file that can be read into a Python dictionary from and external text file.
This is the code
word_dic = eval(open("word.txt").read())
The text file contains the following
'{}maintitle{}': 'pocket', # {}maintitle{} is the text I wished to be replaced by pocket
'{}stylesheet{}': 'generic',
'{}maintitle{}': 'generic',
'{}stylesheet{}': 'generic',
A big thank you in advance