Home >Backend Development >Python Tutorial >What does eval mean in python?
eval means "evaluation". It is a built-in function in python. It is used to execute a string expression and return the calculation result of the expression; that is, when assigning a variable, the right side of the equal sign means Written in string format, the return value is the result of this expression. Syntax "eval(expression[, globals[, locals]])".
The operating environment of this tutorial: windows7 system, python3 version, DELL G3 computer
eval() function
The eval() function is used to execute a string expression and return the value of the expression.
Syntax
eval(expression[, globals[, locals]])
Parameters
● Expression -- Expression.
●globals -- variable scope, global namespace, if provided, must be a dictionary object.
● Locals -- variable scope, local namespace, if provided, can be any mapping object.
Return value
Returns the expression calculation result.
Example:
>>>x = 7 >>> eval( '3 * x' ) 21 >>> eval('pow(2,2)') 4 >>> eval('2 + 2') 4 >>> n=81 >>> eval("n + 4") 85
The above is the detailed content of What does eval mean in python?. For more information, please follow other related articles on the PHP Chinese website!