eval(expression, globals=None, locals=None)
# 返回表达式的计算结果
>> x = 1
>> eval('x+1')
2
# 转换
>> ls = '[1, 2, 3]'
>> eval(ls)
[1, 2, 3]
# 返回表达式的计算结果
>> x = 1
>> eval('x+1')
2
# 转换
>> ls = '[1, 2, 3]'
>> eval(ls)
[1, 2, 3]
转载于:https://www.cnblogs.com/ricecake/p/11275500.html