eval 是干嘛的?...:可以是任何 map 对象
最简单的表达式栗子
栗子一
print(eval("123"))
print(eval("True"))
print(eval("(1,2,3)"))
print(eval(..."[1,2,3]"))
# 输出结果
123
True
(1, 2, 3)
[1, 2, 3]
栗子二
print(eval("1+2"))
x = 1
print(eval('x+1'))...x": 5}
print(eval("x+1", g))
# 输出结果
6
在 eval 中提供了globals 参数
eval 的作用域就是 g 指定的这个字典,外面的 x = 10 被屏蔽掉了...,eval 是看不见的,所以使用了 x 为 5 的值
x = 10
y = 5
g = {"x": 5}
print(eval("x+1+y", g))
# 输出结果
5
print(eval