简体   繁体   中英

How to add .py script to run on another py (python)

I have a python (.py) script. I want to add a code to run guideType.py on gui.py script. When I opening the program it runs gui.py. So I want to be executing that guideType.py when it starts

gui.py = http://dh.st/UsZY

guideType.py = http://dh.st/7SNF

您可以import脚本,这将导致该脚本中的语句被执行。

import gui

Try using os.system("python guideType.py") when you want to execute the second python script. Otherwise, subprocess here might help you achieve what you are asking.

Try something like this

import os, sys

path_python_exec = sys.executable
path_exec_file = ''

command = '%s %s'%(path_python_exec, path_exec_file)
os.system(command)

Customize it according to your needs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM