How to run a python script from IDLE interactive shell?

前端 未结 15 1895
無奈伤痛
無奈伤痛 2020-11-30 17:25

How do I run a python script from within the IDLE interactive shell?

The following throws an error:

>>> python helloworld.py
SyntaxError: i         


        
15条回答
  •  执念已碎
    2020-11-30 18:11

    In Python 3, there is no execFile. One can use exec built-in function, for instance:

    import helloworld
    exec('helloworld')
    

提交回复
热议问题