📜  将 exec 函数分配给变量 python 代码示例

📅  最后修改于: 2022-03-11 14:45:47.317000             🧑  作者: Mango

代码示例1
old_string = "didn't work"
new_string = "worked"

def function():
    exec("global old_string; old_string = new_string")
    print(old_string)

function()