def setglobal(s, x):
# Some kind of eval or exec trick like eval(s+' = '+x) so we end up
# with a global variable whose name is the string s and that has a value of x.
# Take a symbol name s as a string and a value x and eval(s+' = '+x) to set a
# global variable with name s to value x. For getglobal(s) use eval(s).
def setglobal(s, x):
exec "global "+s+"; "+s+" = "+repr(x) in globals()
这似乎有效:
这一定是执行官/考核人的把戏吗?在
相关问题 更多 >
编程相关推荐