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 技術手冊 第三版
248
|
7 章 核心內建功能和標準程式庫模組
tracebacklimit
未處理的例外所顯示的追溯資訊的最大層數(maximum number
of levels of traceback)。預設情況下,這個屬性並未設定(即沒
有限制)。當
sys.tracebacklimit
<=0
Python 只會印出例外型別
和值,不帶追溯資訊(traceback)。
version
描述 Python 版本、建置編號(build number)與日期,以及所
C 編譯器的一個字串。
sys.version[:3]
Python 2.7 來說是
'2.7'
,對 Python 3.5 來說是
'3.5'
,依此類推。
copy 模組
如前面「指定述句」中討論過的,Python 中的指定(assignment)不會複
製(copy)被指定的右手邊物件(righthand-side object),而是新增對右手
邊物件的一個參考(reference)。如果你想要物件
x
的一份拷貝(copy),
你可以向
x
請求它自己的一份拷貝,或是請
x
的型別複製
x
來製作一個新
的實體。如果
x
是一個串列,
list(x)
會回傳
x
的一份拷貝,就跟
x[:]
樣。如果
x
是一個字典,
dict(x)
x.copy()
會回傳
x
的一份拷貝。如果
x
是一個集合,
set(x)
x.copy()
會回傳
x
的一份拷貝。在這每一個情況
中,我們認為最好是使用呼叫型別的那種統一且較易讀的慣用語,但這個
風格議題在 Python 社群中並沒有共識。
copy
模組提供一個 ...
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