I have a string that looks identical to a list, let's say:
'[万福广场西,凰花苑]'
I would like to convert it into something like this:
['万福广场西','凰花苑']
I used eval() and ast.literal_eval() but got error as following:
y=eval('[万福广场西,凰花苑]')
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-117-0aadbead218c> in <module>()
----> 1 y=eval('[万福广场西,凰花苑]')
<string> in <module>()
NameError: name '万福广场西' is not defined
when using ast.literal_eval(), I got this error ValueError: malformed node or string: <_ast.Name object at 0x000002A67FFA5CC0>
malformed node or stringbecause it does NOT look identical to a list, it only look similar.print( '[万福广场西,凰花苑]'.strip("[]").split(",") )?