How to run a python script from IDLE interactive shell?

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

    you can do it by two ways

    • import file_name

    • exec(open('file_name').read())

    but make sure that file should be stored where your program is running

提交回复
热议问题