eval

>>> a="[1,2]"
>>> type(a)
<class 'str'>
>>> a
'[1,2]'
>>> b=eval(a)
>>> b
[1, 2]
>>> type(b)
<class 'list'>
>>> a="[1,221]"
>>> b=eval(a)
>>> b
[1, 221]
>>> c=list(a)
>>> c
['[', '1', ',', '2', '2', '1', ']']
>>> type(c)
<class 'list'>

 

posted @ 2017-11-27 14:52  mlj0503  阅读(136)  评论(0编辑  收藏  举报