How to run a python script from IDLE interactive shell?

前端 未结 15 1894
無奈伤痛
無奈伤痛 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:22

    I tested this and it kinda works out :

    exec(open('filename').read())  # Don't forget to put the filename between ' '
    

提交回复
热议问题