3 :\n prin-6ren">
gpt4 book ai didi

python - Python eval 的扩展

转载 作者:太空宇宙 更新时间:2023-11-04 01:05:16 25 4
gpt4 key购买 nike

<分区>

string = "if X > 3 :\n   print(\"X is Greater\")\nelse :\n   print(\"X is Lesser\")"

""" It prints the string as an indented code of if else statements if X is greater than 3
X is greater else it prints X is lesser"""

X = 6

eval(string)

Python 中的 eval() 可以这样使用吗?我是否遗漏了什么。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com