
以下是从python2.7的 code.py 里复制出来的, 为什么 x=2 没执行到?
filename="<input>" symbol="single" from codeop import CommandCompiler, compile_command compile = CommandCompiler() x=3 print 'before:',x code = compile('x=4\nx=2', filename, symbol) exec code print 'after:',x 结果是:
before: 3 after: 4 source如果有多行,正确格式应该是什么?
1 oglop OP |