Is there a possibility to execute a Python script while being in interactive mode

后端 未结 6 1263
再見小時候
再見小時候 2020-12-23 09:10

Normally you can execute a Python script for example: python myscript.py, but if you are in the interactive mode, how is it possible to execute a Python script

6条回答
  •  悲哀的现实
    2020-12-23 10:05

    You can also use the subprocess module. Something like:

    >>> import subprocess
    >>> proc = subprocess.Popen(['./script.py'])
    >>> proc.communicate()
    

提交回复
热议问题