S
S
sortfact3332021-06-21 21:07:55
Python
sortfact333, 2021-06-21 21:07:55

How to run python file from python file?

I want to run separately a new python file
I tried using

os.system(r'С:\browser\web.py')
   os.startfile(r'С:\browser\web.py')

But the file just opens in my text editor.
Changing the Windows default startup is not an option
. I don't want to create an exe file because I want to be able to edit the file and only then let other users use it without any special programs.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Paul Man, 2021-06-22
@itshack

It is possible like this:

import subprocess
subprocess.run(["C:\\python\\python_370\\python.exe", "web.py"])

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question