python eval函数,将列表样式的字符串转化为列表

python eval函数,将列表样式的字符串转化为列表

>>> str_1 = '[1,2,3,4,5,6]'
>>> type(str_1)
<type 'str'>
>>> list_1 = eval(str_1)
>>> list_1
[1, 2, 3, 4, 5, 6]
>>> type(list_1)
<type 'list'>
>>>

posted @ 2018-06-14 12:05  秋华  阅读(2496)  评论(0编辑  收藏  举报