第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定

isinstance的參數(shù)

isinstance的參數(shù)是不是只能是str?還是分不同情況

正在回答

1 回答

isinstance函數(shù)的原型是:


isinstance(object,?classinfo)


Return true if the?object?argument is an instance of the?classinfo?argument, or of a (direct or indirect) subclass thereof. Also return true if?classinfo?is a type object (new-style class) and?object?is an object of that type or of a (direct or indirect) subclass thereof. If?object?is not a class instance or an object of the given type, the function always returns false. If?classinfo?is neither a class object nor a type object, it may be a tuple of class or type objects, or may recursively contain other such tuples (other sequence types are not accepted). If?classinfo?is not a class, type, or tuple of classes, types, and such tuples, a?TypeError?exception is raised.

Changed in version 2.2: Support for a tuple of type information was added.

其中的classinfo指的是某種類型,比如常用的unicode:?
isinstance(some_str, unicode)?
來判斷是否是unicode類型的字符。但是想要知道其他還有哪些類型,網(wǎng)上沒找到具體說明,后來還是自己在python安裝后,自帶的的英文manual中找到了:

5.4. Numeric Types —?int,?float,?long,?complex

5.6. Sequence Types —?str,?unicode,?list,?tuple,?bytearray,?buffer,?xrange

5.7. Set Types —?set,?frozenset

5.8. Mapping Types —?dict

這樣,才知道,關(guān)于想要判斷某個(gè)變量的類型,就可以去手冊里面找到對應(yīng)的變量名,然后測試是否是該類型變量了。

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

qq_神的一滴_03589442 提問者

非常感謝:多謝多謝,辛苦辛苦
2016-07-07 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消
初識Python
  • 參與學(xué)習(xí)       758365    人
  • 解答問題       8967    個(gè)

學(xué)python入門視頻教程,讓你快速入門并能編寫簡單的Python程序

進(jìn)入課程

isinstance的參數(shù)

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號