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 技術手冊 第三版
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.

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

測試驅動開發|使用 Python

Harry J.W. Percival

Publisher Resources

ISBN: 9789864766819