简体   繁体   中英

Call python script from python script

I am trying to call a python script out of a python script and I don't know how to solve my problem. For Linux OS I used to use "touch XYZ.py" and made it an executable script to be run in a different terminal. The results would than be saved to a text file, where the "mother"-script could access them. However I try to make it usable across all platforms. Basically I would like to use only python without the need to interact with the OS.

Thanks for any help

This may be a bit clunky, but here it is:

import os
os.system("python Path/To/Script")

This should work cross-platform, like you asked. Or like the comment said, just import the script.

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