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 技術手冊 第三版
資料型別
|
55
Python
唯一不能成為三引號字串內容一部分的字元是未轉義(unescaped)的反
斜線,然而一個帶引號字串(quoted string)不能包含未轉義的反斜線、
斷行,或是圍住它的引號字元。反斜線字元起始一個
轉義序列
escape
sequence
,這能讓你在上述任一種字串中引入任何字元。我們在表 3-1
列出了 Python 的字串轉義序列。
3-1 字串轉義序列
序列 意義 ASCII/ISO 代碼
\<newline>
忽略行結尾
\\
Backslash(反斜線)
0x5c
\'
Single quote(單引號)
0x27
\"
Double quote(雙引號)
0x22
\a
Bell
0x07
\b
Backspace(退格)
0x08
\f
Form feed
0x0c
\n
Newline(新行)
0x0a
\r
Carriage return
0x0d
\t
Ta b
0x09
\v
Vertical tab
0x0b
\ DDD
八進位值
DDD
如給定的
\x XX
十六進位值
XX
如給定的
\ other
任何其他(other)字元:一個雙字元的字串
0x5c
+ 如給定的
字串字面值的一個變體是
原始字串
raw string
。語法跟帶引號或三引號
字串字面值相同,只不過前導引號的前面緊接著一個
r
R
。在原始字串
中,轉義序列不會像表 3-1 所記載的那樣被解讀,而是照字面被複製到字
串中,包括反斜線和 newline 字元。原始字串語法適用於包含許多反斜線
的字串,特別是正規表達式的模式(regular expression ...
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