Python capture all printed output
问题 I am looking to write console based programs in python that can execute functions to perform generic tasks, pretty generic. Is it possible to capture everything written to the console by print calls in a function without needing to return a string, similar to how bash and the windows shell allow piping the output of a program to a text file, ie ipconfig>ipconfig.txt but doing this inside of a python program, where a function is called, everything that was printed to the console inside of that