What's the difference between eval, exec, and compile?

后端 未结 3 1981
梦谈多话
梦谈多话 2020-11-21 23:26

I\'ve been looking at dynamic evaluation of Python code, and come across the eval() and compile() functions, and the exec statement.

3条回答
  •  天命终不由人
    2020-11-22 00:05

    exec is for statement and does not return anything. eval is for expression and returns value of expression.

    expression means "something" while statement means "do something".

提交回复
热议问题