0
>>> compile("""
def some_function(x):
return x+2
some_function""",'compiled function','single')
Traceback (most recent call last):
File "<pyshell#3>", line 4, in <module>
some_function""",'compiled function','single')
File "compiled function", line 4
some_function
^
SyntaxError: unexpected EOF while parsing
這不是Python 3代碼。 – ThePiercingPrince
@LinuxDistance:只要將'exec'變成一個函數調用,它就可以工作。 Python 3和Python 2沒有那麼不同。 – Blender