Skip to Content
Python 技術手冊 第三版
book

Python 技術手冊 第三版

by lex Martelli, Anna Martelli Ravenscroft, Steve Holden
January 2018
Intermediate to advanced
856 pages
17h 17m
Chinese
GoTop Information, Inc.
Content preview from Python 技術手冊 第三版
267
8
字串類的東西
v3 以型別
str
支援 Unicode 文字字串(text strings),具有運算子、內建函
式、方法,以及專用的模組。它也提供在某些方面類似的
bytes
型別,以
位元組序列(sequence of bytes)表示任意的二進位資料(binary data),
也被稱為
bytestring
位元組字串
byte string
。這是與 v2 的主要差
異,在 v2 中,
str
是位元組所成的序列,而 Unicode 文字字串的型別則是
unicode
。許多文字運算,在兩個版本中,都能在其中任一個型別的物件上
進行。
本章在「字串與位元組物件的方法」一節中涵蓋字串物件的方法,在「字
串格式化」中涵蓋字串的格式化,並涵蓋模組
string
(「 string 模組」中)
pprint
(「 pprint 模組」中)。與 Unicode 有關的特定議題也有涵蓋,在
後面的「Unicode」中。新的(v3.6)格式化字串字面值(formatted string
literals)涵蓋於「3.6 中的新功能:格式化字串字面值」。
字串與位元組物件的方法
Unicode
str
bytes
物件是不可變的序列(immutable sequences),如前
面「字串」一節中所涵蓋的。不可變序列的所有運算(重複、串接、索引
與切片)都能套用到它們身上,並會回傳相同型別的一個物件。字串或位
元組物件
s
也提供了數個非變動式的方法,如表 8-1 中所記載。
268
|
8 章 字串類的東西
除非特別提到,不然上述任一個型別的物件上都有這些方法可用 ...
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 进行数据分析(原书第2版)

利用 Python 进行数据分析(原书第2版)

Wes McKinney

Publisher Resources

ISBN: 9789864766819