Skip to content
Advertisement

how to use external scripts from main python file

so have 2 python project file one is qr scanner and other is youtube downloader. adn both are in different python file

so i wanna create an main python file where i will list the both project name like:

  1. Qr Scanner
  2. YouTube Downloader Enter You Option:

So when the user input their option. the script will gonna run in background using another terminal…

i searched in internet i dont understand anything so i didnt tried anything else

i dont know how to do it and where to start it

Advertisement

Answer

It sounds like subprocess is what you want. It allows you to make command line calls by passing arguments to .run() method.

For example, you can call the ls bash command to get a list of files in the current directory.

import subprocess as sp
out = sp.run("ls", capture_output=True)
print(out.sdtout)
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement