I have a string "[u'foo']"
(Yes, it includes the square brackets and the u''
). I have to convert that to a list which looks like [u'foo']
.
list("[u'foo']")
won't work.
Any suggestions?
I have a string "[u'foo']"
(Yes, it includes the square brackets and the u''
). I have to convert that to a list which looks like [u'foo']
.
list("[u'foo']")
won't work.
Any suggestions?
>>> import ast
>>> s = "[u'foo']"
>>> ast.literal_eval(s)
[u'foo']