Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有这样的命令:
test = ('print( "It works!" )' )
我想使用该字符串内部的命令。你知道我怎样才能提取和使用它吗?
非常感谢你,莱姆斯
使用exec但确保您信任代码,即。出于安全原因,不要在用户提交的代码上运行它
exec
>>> test = ('print( "It works!" )' ) >>> exec test It works!