EXEC description
EXEC executes python statements stored in a string or file, and can execute more complex Python code than eval,exec.
return value
The exec return value is always None.
It should be explained that exec is not a function in Python2, but a built-in statement (statement), but there is a execfile () function in Python 2.
It can be understood that Python 3 consolidates the functionality of the EXEC statement and execfile () functions into a new EXEC () function.
Eval description
The eval () function is used to execute a string expression and return the value of the expression
return value
Returns the result of an expression evaluation.
exec and eval similarities and differences
1.Exec can handle the code inside the string (the expression + code that conforms to the Python syntax), and eval can only handle expressions inside the string.
2.exec no return value; eval () is the execution of an expression with a return value, such as a=eval (' + + ').
Both 3.exec and Eval can execute functions in strings such as: Exec (func (n)), eval (func (n)).
exec and Eval in Python