简体   繁体   中英

Execute and create one python script from another

Suppose, I have a python script test1.py , executing of test1.py will create a copy of that file, let's say test2.py . Now, I want to run test1.py in such a way that first it will create test2.py and then will execute test2.py .

This is my test1.py python script looks like,

import io
import shutil
import os

shutil.copy2('test1.py', 'test2.py')
os.system("test2.py")

But out is saying test2.py: not found

Run python with test2.py as it's first argument.

os.system("python test2.py")

If you say what's your goal of this action. We can help you better.

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