首页 > 编程 > Python > 正文

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

2019-11-08 19:41:31
字体:
来源:转载
供稿:网友

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


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表