From the course: Learning the Python 3 Standard Library

Unlock the full course today

Join today to access over 24,700 courses taught by industry experts.

Text wrap module

Text wrap module

- [Instructor] Let's figure out how to format text with the text wrap module. And in order to use this module, we need to import it. And so we're going to go import textwrap, and we'll go ahead and print the text without any dedenting. And we'll learn what that means in a minute. So we'll go print(textwrap.fill(websiteText)). And so printing this out, you'll see that when we printed it, it kept this beginning space that we had up here, but it didn't keep our Enters, meaning it broke our text at different places. So it kind of edited it on its own and filled a certain particular space, but still kept this beginning tab here. This is one way that you could display your text. Another way is to have dedenting. And what this is going to do is it's going to take away our beginning and later spaces, and it's going to keep the Enters that we had here. It's not going to reformat them. And so in order to create dedent text,…

Contents