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 技術手冊 第三版
內建函式
|
239
isinstance isinstance(obj,cls)
obj
是類別
cls
(或
cls
任何子類別)的一個實體時回傳
True
,否則的
話,就回傳
False
cls
可以是其項目為類別的一個元組(tuple):在這種
情況下,如果
obj
cls
中任何項目的實體,
isinstance
就會回傳
True
否則的話,它會回傳
False
。也請參閱前面的「抽象基礎類別」。
issubclass issubclass(cls1,cls2)
cls1
cls2
的一個直接或間接子類別,就回傳
True
。否則,回傳
False
cls1
cls2
必須是類別。
cls2
也可以是一個元組,其中的項目
是類別。在這種情況中,
issubclass
會在
cls1
cls2
中任何項目的直接
或間接子類別的時候回傳
True
,否則就回傳
False
。對於任何的類別
C
issubclass(C,C)
永遠是
True
iter iter(obj) iter(func,sentinel)
創建並回傳一個
迭代器
iterator,也就是你可以重複傳入內建函式
next
來一次取得一個項目的一種物件(參閱前面的「迭代器」)。以一個引數
呼叫時,
iter(obj)
正常會回傳
obj.__iter_ _()
。當
obj
是沒有特殊方法
__iter_ _
的一個序列,
iter(obj)
就等同於這個產生器:
def iter_sequence(obj):
i = 0
while True:
try: yield o bj[i]
except In ...
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