Skip to Content
Introducing Python, 3rd Edition
book

Introducing Python, 3rd Edition

by Bill Lubanovic
September 2025
Beginner to intermediate
660 pages
12h 48m
English
O'Reilly Media, Inc.
Content preview from Introducing Python, 3rd Edition

Chapter 17. Text Data

I live for the text. It’s my job.

Ian McKellen

You saw the basics of Python strings in Chapter 4. Now it’s time to dig deeper into strings and text data.

Text Strings: Unicode

Python 3 strings are Unicode character sequences, not bytearrays. This is, by far, the single largest language change from Python 2.

All the text examples in this book thus far have been plain old ASCII. ASCII was defined in the 1960s, before mullets roamed the earth. Computers then were the size of refrigerators, and only slightly smarter.

As I mentioned way back in Chapter 2, the basic unit of computer storage is the byte, which can store 256 unique values in its eight bits. For various reasons, ASCII used only seven bits (128 unique values): 26 uppercase letters, 26 lowercase letters, 10 digits, some punctuation symbols, some spacing characters, and some nonprinting control codes.

Unfortunately, the world has more letters than ASCII provides. You could have a hot dog at a diner, but never a Gewürztraminer at a café.1 Many attempts have been made to cram more letters and symbols into eight bits, and you’ll see them at times.

Here are just a couple of those:

  • Latin-1, or ISO 8859-1

  • Windows code page 1252

Each of these uses all eight bits, but even that’s not enough, especially when you need non-European languages. Unicode is an ongoing international standard to define the characters of all the world’s languages, plus symbols from mathematics and other fields. And emojis!

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Introducing Python, 2nd Edition

Introducing Python, 2nd Edition

Bill Lubanovic

Publisher Resources

ISBN: 9781098174392Errata Page