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'>
>>>

猜你喜欢

转载自www.cnblogs.com/qiu-hua/p/9182444.html
今日推荐