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 - Python Tutorial
From the course: Learning the Python 3 Standard Library
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,…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
Getting the current time with Python2m 7s
-
(Locked)
Formatting dates and times in Python with datetime3m 46s
-
(Locked)
Calculating future times and Python calendar module3m 26s
-
(Locked)
Create a timer with the Python time module2m 50s
-
(Locked)
Python HTML parser module7m 17s
-
(Locked)
Text wrap module4m 23s
-
(Locked)
Python HTTP package and urllib and JSON modules6m 34s
-
(Locked)
Solution: Add Fractions with Fraction Module59s
-
-