Python中eval,exec这两个函数有着相似的输入参数类型和执行功能,因此在用法上经常出现混淆,以至经常用错,程序易抛出错误.下面主要通过这两个函数的语法来阐述区别,并用例子来进一步说明. 首先看下官方文档对这两个函数的说明: (1)eval(expr, globals=None, locals=None, /) Evaluate the given expr in the context of globals and locals. This call returns the expr…
2.1 Built-in Functions The Python interpreter has a number of functions built into it that are always available. They are listed here in alphabetical order. __import__( name[, globals[, locals[, fromlist]]]) This function is invoked by the import sta…