当前位置:网站首页>Eval function, global, local variables
Eval function, global, local variables
2022-06-27 20:29:00 【LRJ-jonas】
eval() function :
a=10; print(eval("a+1"))eval Function will “ String text ” Change to code variable
stay Python in evel() The syntax format of the function is eval(expression, globals=None, locals=None)
global:g local:t
a=10
b=20
c=30
g={'a':6,'b':8}
t={'b':100,'c':10}
print(eval('a+b+c',g,t))
a and c Go to the dictionary respectively g And the dictionary t The value in , When globals and locals There are parameters in b You take locals The value in . therefore a=6,b=100,c=10. The running result is 116
application : You can use one line of code to implement the functions of the calculator print(eval(input(' Please enter '))).
shortcoming : But because it has the ability to convert strings into expressions for execution , So it can execute system commands . This can easily be used by people with ulterior motives to execute system commands , Delete key system files .
边栏推荐
- database engine
- 回溯相关问题
- [login interface]
- (LC)46. Full Permutation
- muduo
- 低代码开发平台是什么?为什么现在那么火?
- [array]bm99 clockwise rotation matrix - simple
- Type the URL to the web page display. What happened during this period?
- Web APLS phase - Section 14 - local storage
- OpenSSL client programming: SSL session failure caused by an obscure function
猜你喜欢

CSDN 技能树使用体验与产品分析(1)

数据库日志

微信iOS版8.0.24更新发布 缓存细分清理上线

Observable, reliable: the first shot of cloudops series Salon of cloud automation operation and maintenance

UE4: explanation of build configuration and config

谈谈我写作生涯的画图技巧

Pfsense plus22.01 Chinese customized version release

Ble Bluetooth module nrf518/nrf281/nrf528/nrf284 chip scheme comparison

数仓的字符截取三胞胎:substrb、substr、substring

Pointers and structs
随机推荐
Data intelligence enters the "deep water area", and data governance is the key
Question brushing record: easy array (continuously updated)
Csdn Skills Tree use Experience and Product Analysis (1)
UE4: explanation of build configuration and config
安装NFS服务
[数组]BM99 顺时针旋转矩阵-简单
Longitude and latitude analysis
Hanoi Tower problem
CSDN 技能樹使用體驗與產品分析(1)
UE4 realizes long press function
在开发数字藏品时,文博机构该如何把握公益和商业的尺度?如何确保文物数据的安全?
Postman Chinese tutorial (postman Chinese version)
Select auto increment or sequence for primary key selection?
UE4随笔:FString、FName 与 FText
Binary tree related problems 2
1025 PAT Ranking
What is a stack?
Web APls 阶段——第十四节——本地存储
Backtracking related issues
NVIDIA三件套环境配置