I'm trying to write a program that will read what text is printed to the console, and do something with that information. For example, if another Python program called print("Test.") my program would get "test." Or, if you typed echo This is a message my program would get "This is a message". Is there a way to do this?
Asked
Active
Viewed 42 times
0
-
This isn't a very clear question. I think your question is better asked and answered here. https://stackoverflow.com/questions/4675728/redirect-stdout-to-a-file-in-python?noredirect=1&lq=1 – Grape Dragon Jun 02 '21 at 14:57
-
Hi. This doesn't answer the question, because when changing sys.stdout, stdout isn't printed anymore. I want to get, I think it's called the console's string buffer? Not sure on the Windos terminology, but to get whatever is printed to stdout and handle it. – Turret Jun 02 '21 at 15:10
-
Oh, in that case this is an interesting question. You should probably clean up the question a bit, provide pseudocode, desired outputs and whatnot. – Grape Dragon Jun 02 '21 at 15:32