为什么这不起作用?
f = lambda A, B:[eval(i) for i in 'AB']
在Python 3中,返回以下错误:
Traceback (most recent call last):
File "python", line 1, in <module>
File "python", line 1, in <lambda>
File "python", line 1, in <listcomp>
File "<string>", line 1, in <module>
NameError: name 'A' is not defined
尝试f(1, 2)
时。但是,该函数肯定会返回[1, 2]
...