Back to Browse

How to Capture What Is Written to stdout in Python

5.8K views
Sep 7, 2021
6:02

In this Python tutorial, you'll learn how to redirect what is written to stdout in Python. This can be helpful when dealing with functions like the built-in help function. First, we will have a look at the built-in help function and why it is a perfect candidate for the task at hand. Secondly, I'll show you how to redirect everything from stdout to a text file. Lastly, we will see how to capture what is written to stdout in a string variable, so we can do whatever we would like to do with the text. GitHub Repository https://github.com/DahlitzFlorian/capture-stdout-output-video-snippets SUBSCRIBE to become a Pythonista! https://www.youtube.com/channel/UCWLhIFVgFNexbE_T0e-X5vw?sub_confirmation=1 Follow me on Twitter! https://twitter.com/DahlitzF Check out my website for more! https://florian-dahlitz.de/become-a-pythonista ~~~~~~~~~~ OUTLINE ~~~~~~~~~~ 00:00 Introduction 00:14 Built-in help function 01:21 Send stdout to a file 03:19 Send stdout to stderr 03:54 Capture stdout in a variable #python

Download

0 formats

No download links available.

How to Capture What Is Written to stdout in Python | NatokHD