How to call a Python script in command line from another python script?

131 views Asked by At

I have two python scripts, which need two different python versions (3.6 or older and 3.8 or newer). To get the information produced from the older versioned script, I want to call it in the newer script on command line and save the results to a file, so that I can use it in the newer Script.

What's the best way to call my older script on command line from the newer one?

1

There are 1 answers

1
Yanni2 On

You could use the os librar to run it.

import os
os.system("py example.py")