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

Python 技術手冊 第三版

by lex Martelli, Anna Martelli Ravenscroft, Steve Holden
January 2018
Intermediate to advanced content levelIntermediate to advanced
856 pages
17h 17m
Chinese
GoTop Information, Inc.
Content preview from Python 技術手冊 第三版
274
|
8 章 字串類的東西
octdigits
字串
'01234567'
punctuation
字串
'!"#$%&\'( )*+,-./:;<=>?@[\]^_'{|}~'
(即在
'C'
locale 中被視為
標點符號字元的所有 ASCII 字元,不取決於所啟用的 locale
printable
被視為可列印(printable)的那些 ASCII 字元(即數字、字母、標點符
號與空白)所成的字串
whitespace
含有被視為空白(whitespace)的所有 ASCII 字元所成的一個字串:
至少有空格(space)、 tablinefeed carriage return,但還可能出現
更多的字元(例如特定的控制字元),取決於所啟用的 locale(地區設
)。
你不應該重新繫結(rebind)這些屬性,這麼做的效果是未定義的,因為
Python 程式庫的其他部分可能仰賴它們。
string
模組也提供類別
Formatter
,涵蓋於後面的「字串格式化」。
字串格式化
v3 引進了一種強大的字串格式化新機能,它也被後向移植到了 v2
Unicode 字串(但在 v3 中,
不包含
bytestrings)提供了一個
format
方法,
你可用引數來呼叫以內插(interpolate)至格式字串,其中要被格式化的值
會以圍在大括號(braces)中的取代欄位(replacement fields)來表示。
格式化的過程最好是理解成一連串的作業,每個都由其取代欄位來指引。
首先,要被格式化的每個值會被 ...
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.
Start your free trial

You might also like

測試驅動開發|使用 Python

測試驅動開發|使用 Python

Harry J.W. Percival
Linux 内核观测技术BPF

Linux 内核观测技术BPF

David Calavera, Lorenzo Fontana

Publisher Resources

ISBN: 9789864766819