将字符串编译成python 能识别或可执行的代码
s="print('hello world')"
r=compile(s,"<string>","exec")
print(r)
exec(r)
out:
<code object <module> at 0x7f08133268a0, file "<string>", line 1>
hello world
将字符串编译成python 能识别或可执行的代码
s="print('hello world')"
r=compile(s,"<string>","exec")
print(r)
exec(r)
out:
<code object <module> at 0x7f08133268a0, file "<string>", line 1>
hello world