Skip to Content
Introdução ao Python, 3rd Edition
book

Introdução ao Python, 3rd Edition

by Bill Lubanovic
September 2025
Intermediate to advanced
660 pages
13h 38m
Portuguese (Portugal, Brazil)
O'Reilly Media, Inc.
Content preview from Introdução ao Python, 3rd Edition

Capítulo 17. Dados de texto

Este trabalho foi traduzido com recurso a IA. Agradecemos o teu feedback e comentários: translation-feedback@oreilly.com

Eu vivo para o texto. É o meu trabalho.

Ian McKellen

Você viu os conceitos básicos de strings do Python no Capítulo 4. Agora é hora de se aprofundar em strings e dados de texto.

Strings de texto: Unicode

As cadeias de caracteres do Python 3 são sequências de caracteres Unicode, não bytearrays. Essa é, de longe, a maior mudança de linguagem em relação ao Python 2.

Todos os exemplos de texto deste livro até agora foram o velho e simples ASCII. O ASCII foi definido na década de 1960, antes de as mullets existirem, e os computadores daquela época tinham o tamanho de geladeiras e eram apenas um pouco mais inteligentes.

Como mencionei no Capítulo 2, a unidade básica de armazenamento do computador é o byte, que pode armazenar 256 valores exclusivos em seus oito bits. Por vários motivos, o ASCII usava apenas sete bits (128 valores exclusivos): 26 letras maiúsculas, 26 letras minúsculas, 10 dígitos, alguns símbolos de pontuação, alguns caracteres de espaçamento e alguns códigos de controle não impressos.

Infelizmente, o mundo tem mais letras do que o ASCII oferece. Você poderia comer um cachorro-quente em uma lanchonete, mas nunca um Gewürztraminer em um café.1 Muitas tentativas foram feitas para colocar mais letras e símbolos em oito bits, e você as verá algumas vezes.

Aqui estão apenas algumas delas:

  • Latin-1, ou ISO 8859-1

  • Página de ...

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

Python Distilled

Python Distilled

David M. Beazley
Python in a Nutshell, 4th Edition

Python in a Nutshell, 4th Edition

Alex Martelli, Anna Martelli Ravenscroft, Steve Holden, Paul McGuire

Publisher Resources

ISBN: 9798341668850