How to run a python script from IDLE interactive shell?

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

    For example:

    import subprocess
    
    subprocess.call("C:\helloworld.py")
    
    subprocess.call(["python", "-h"])
    

提交回复
热议问题