How to run a python script from IDLE interactive shell?

前端 未结 15 1870
無奈伤痛
無奈伤痛 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条回答
  •  Happy的楠姐
    2020-11-30 18:14

    execFile('helloworld.py') does the job for me. A thing to note is to enter the complete directory name of the .py file if it isnt in the Python folder itself (atleast this is the case on Windows)

    For example, execFile('C:/helloworld.py')

提交回复
热议问题