S
S
SuperZombie2021-02-19 22:53:23
Python
SuperZombie, 2021-02-19 22:53:23

How to write the contents of the console to a variable in Python?

system("Decoder.bat")
This is a piece of a program that, as a result of its work, displays text in the console.
It prints the following message to the console:

1234.wav
Decoding to 16000 Hz (1 channel)
Encoded with libopus unknown-fixed
Decoding complete.

This message is displayed if successful.

Sometimes it gives an error to the console.
Q: How to track it? I have a suggestion to get the text from the console into a variable, and then parse it.
Help me please.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Ruslan., 2021-02-19
@SuperZombie

You can try to redirect the output to the file
system("Decoder.bat >>1.txt")
And then read the text from it and parse it.

S
Sergey Karbivnichy, 2021-02-19
@hottabxp

Didn't understand anything, but most likely you should use subprocessinsteadsystem

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question