python中eval()函数官方文档的说明
来源:互联网 发布:淘宝互刷信誉平台 编辑:程序博客网 时间:2024/05/24 22:42
eval
(expression, globals=None, locals=None)The arguments are a string and optional globals and locals. If provided, globals must be a dictionary. If provided, locals can be any mapping object.
The expression argument is parsed and evaluated as a Python expression (technically speaking, a condition list) using the globals and locals dictionaries as global and local namespace. If the globals dictionary is present and lacks ‘__builtins__’, the current globals are copied into globals before expression is parsed. This means that expressionnormally has full access to the standard builtins
module and restricted environments are propagated. If the locals dictionary is omitted it defaults to the globals dictionary. If both dictionaries are omitted, the expression is executed in the environment where eval()
is called. The return value is the result of the evaluated expression. Syntax errors are reported as exceptions. Example:
This function can also be used to execute arbitrary code objects (such as those created by compile()
). In this case pass a code object instead of a string. If the code object has been compiled with 'exec'
as the mode argument, eval()
’s return value will be None
.
Hints: dynamic execution of statements is supported by the exec()
function. The globals()
and locals()
functions returns the current global and local dictionary, respectively, which may be useful to pass around for use by eval()
or exec()
.
See ast.literal_eval()
for a function that can safely evaluate strings with expressions containing only literals.
- python中eval()函数官方文档的说明
- python的eval()函数
- python 的eval()函数
- Oracle 官方文档 结构说明(教你如何快速从官方文档中获取需要的知识)
- Oracle官方文档结构说明(教你如何快速从官方文档中获取需要的知识)
- Oracle官方文档结构说明(教你如何快速从官方文档中获取需要的知识)
- python eval函数的作用
- Python eval 函数的使用
- Python eval 函数的滥用
- Java中类似于eval()的函数?
- JS中eval()函数的重要性
- python中eval和exec函数的应用
- Python中eval()函数的功能及使用方法
- python 中 eval函数,exec与eval对不
- python中eval的使用
- python中eval()的妙用
- runspec 的选项说明(spec2006官方文档的翻译)
- perl函数说明(eval)
- MySQL基础教程16-Mysql数据类型-浮点型和定点型
- GLSL,CUDA语言概念以及VisualSFM限制
- 多线程创建同级目录和上下级目录
- ubuntu14.04上网
- Python实现一个简单的图片爬虫
- python中eval()函数官方文档的说明
- GreenDao的使用
- 开通博客
- 异步Socket通信编程的C#实现(2)
- 输入三条边并判断是否为三角形,若能构成三角形,指出其为何种三角形:等边、直角亦或者一般三角形
- 循环数比较
- ERROR: bootstrap checks failed max file descriptors [4096] for elasticsearch process likely too low,
- 存储器(一)
- HTML中可能使用为协议造成XSS 的属性