1) I store info for some python code in a dict
2) I was storing that dict in an indigo variable using str(myDict)
3) I was retrieving the indigo variable into a python script, converting it from a string to dict using myDict = ast.literal_eval()
4) The contents of the dict appear to be Unicode now, causing problems in my script
Jay instructed me to convert the dict to json before storing in an indigo variable
Question: How do I reproduce this Unicode-related problem on my python editor outside of indigo?
I tried this
- Code: Select all
import ast
unicodeString = unicode("{'key1':'value1', 'key2':'value2'}")
uDict = ast.literal_eval(unicodeString)
But it yields this:
- Code: Select all
>>> uDict['key1']
'value1
Not this:
- Code: Select all
u’value1’
Thoughts?
Sent from my iPhone using Tapatalk