Chapter 6. Strings

After numbers, strings are the most important data type in Python. Strings are ubiquitous: You print them to the screen, you read them from the user, and, as we will see in Chapter 8, files are often treated as big strings. The World Wide Web can be thought of as a collection of Web pages, most of which consist of text. Plus the XML markup language, which is entirely text based, has become a popular file format for packages such as Microsoft Office.

Strings are a good example of an aggregate data structure, and they provide our first look at indexing and slicing—techniques that are used to extract substrings from strings.

The chapter also contains a brief introduction to Python’s regular expression library, which is a supercharged ...

Get Python: Visual QuickStart Guide, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.