【发布时间】:2013-05-30 19:48:36
【问题描述】:
在 python3 中,当我运行时
>>> exec("","","")
TypeError: exec() arg 2 must be a dict, not str
>>> exec( "print('Hello')", print("World"), print("!") )
World
!
Hello
>>> type(print("World"))
World
<class 'NoneType'>
我的意思是在 Python3 中, exec() 的 arg2 需要一个 dict,但我们仍然可以放置一个不是 dict 的 print() 函数。为什么?
【问题讨论】:
标签: python python-3.x python-exec