我一直在寻找的Python代码动态评估,并遇到了eval()和compile()功能,以及exec声明.
有人可以解释之间的区别eval和exec怎样的不同模式,compile()适应吗?
在尝试使用Python的"exec"语句时,我收到以下错误:
TypeError: exec: arg 1 must be a string, file, or code object
Run Code Online (Sandbox Code Playgroud)
我不想传入字符串或文件,但什么是代码对象,我该如何创建?