What does python eval mean?

藏色散人
Release: 2019-08-01 15:48:41
Original
9175 people have browsed it

What does python eval mean?

Python (pronounced: British [ˈpaɪθən], American [ˈpaɪθɑ:n]) is an object-oriented, literal translation computer programming language and a powerful general-purpose language. , has a development history of nearly 20 years, is mature and stable. It contains a complete and easy-to-understand standard library that can easily complete many common tasks.

Its syntax is very simple and clear. Unlike most other programming languages, it uses indentation to define statements.

What does python eval mean?

The python eval() function is used to execute a string expression and return the value of the expression.

The following is the syntax of the eval() method:

eval(expression[, globals[, locals]])
Copy after login

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.

The following shows an example of using the eval() method:

>>>x = 7 >>> eval( '3 * x' ) 21 >>> eval('pow(2,2)') 4 >>> eval('2 + 2') 4 >>> n=81 >>> eval("n + 4") 85
Copy after login

Related recommendations: "Python Tutorial"

The above is the detailed content of What does python eval mean?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!