当前位置: 首页 > 图灵资讯 > 行业资讯> python中的exec()函数用法

python中的exec()函数用法

发布时间:2024-10-09 15:25:58

参数:

objectglobals、locals——可选参数、全局变量、局部变量。

返回值:

返回值为none。

实例演示:

withopen("data.txt","r",)asf:
forlineinf.readlines():
exec(line)
print("speed=",speed,type(speed))

输出结果:

speed:20<class'int'>

关于exec()函数的使用介绍到此结束。整个过程结束后,各方面都做了详细的介绍,希望对大家有所帮助。

相关文章

python3兼容python2吗

python3兼容python2吗

2025-05-09
python3 whl怎么安装

python3 whl怎么安装

2025-05-09
python 字典怎么提取value

python 字典怎么提取value

2025-05-09
python 怎样计算字符串的长度

python 怎样计算字符串的长度

2025-05-09
python 怎么样反向输出字符串

python 怎么样反向输出字符串

2025-05-09
python 怎么判断字符串开头

python 怎么判断字符串开头

2025-05-09