[英]Is there a way to convert list of string formatted dictionary to a dataframe in Python?
[英]Python convert formatted string to list
我有一個字符串"[u'foo']"
(是的,它包括方括號和u''
)。 我必須將其轉換為看起來像[u'foo']
的列表。
list("[u'foo']")
將不起作用。
有什么建議么?
>>> import ast
>>> s = "[u'foo']"
>>> ast.literal_eval(s)
[u'foo']
eval("[u'foo']", {'__builtins__':[]}, {})
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.