why exec('print(x)') is executed while print(x) goes wrong in this python code?

前端 未结 0 1262
情话喂你
情话喂你 2020-12-23 20:54
def build(s, loc):
    exec(s, loc)
    return loc

def main():
    L = build(\'x = 1\', locals())
    locals().update(L)
    exec(\'print(x)\')

  
if __name__ == \         


        
相关标签:
回答
  • 消灭零回复
提交回复
热议问题