@eval()_function

Publicado el: 01 enero 1970
en el canal de: Nielit Online Academy By Satya Sir
33
3

Understanding Python’s eval()
You can use the built-in Python eval() to dynamically evaluate expressions from a string-based or compiled-code-based input. If you pass in a string to eval(), then the function parses it, compiles it to bytecode, and evaluates it as a Python expression. But if you call eval() with a compiled code object, then the function performs just the evaluation step, which is quite convenient if you call eval() several times with the same input.

The signature of Python’s eval() is defined as follows:

eval(expression[, globals[, locals]])
The function takes a first argument, called expression, which holds the expression that you need to evaluate. eval() also takes two optional arguments:

globals
locals
In the next three sections, you’ll learn what these arguments are and how eval() uses them to evaluate Python expressions on the fly.

Python eval() Function

Example
Evaluate the expression 'print(55)':

x = 'print(55)'
eval(x)
Definition and Usage
The eval() function evaluates the specified expression, if the expression is a legal Python statement, it will be executed.

Syntax
eval(expression, globals, locals)
Parameter Values
Parameter Description
expression A String, that will be evaluated as Python code
globals Optional. A dictionary containing global parameters
locals Optional. A dictionary containing local parameters


En esta página del sitio puede ver el video en línea @eval()_function de Duración hora minuto segunda en buena calidad , que subió el usuario Nielit Online Academy By Satya Sir 01 enero 1970, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 33 veces y le gustó 3 a los espectadores. Disfruta viendo!