K
K
Kactus2020-04-19 13:54:16
Python
Kactus, 2020-04-19 13:54:16

How to put the result from os.system into a variable?

hello everyone, how to put the result from os.system into a variable. If you put in , then the console will display the work of this program, and in it will be 0 a = os.system("youtube-dl -параметры")print(a)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Yakushenko, 2020-04-19
@Kactus

os.system only starts the process, it doesn't capture the result.
If you need to get the result of the execution, then as an option you can do it like this:

import subprocess

a = subprocess.check_output('youtube-dl -параметры', shell=True)

Or use Popen

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question