Python實用內建函式

2021-10-24 22:42:28 字數 1731 閱讀 2227

內建函式

abs()

dict()

help()

min()

setattr()

all()

dir()

hex()

next()

slice()

any()

divmod()

id()

object()

sorted()

ascii()

enumerate()

input()

oct()

staticmethod()

bin()

eval()

int()

open()

str()

bool()

exec()

isinstance()

ord()

sum()

bytearray()

filter()

issubclass()

pow()

super()

bytes()

float()

iter()

print()

tuple()

callable()

format()

len()

property()

type()

chr()

frozenset()

list()

range()

vars()

classmethod()

getattr()

locals()

repr()

zip()

compile()

globals()

map()

reversed()

__import__()

complex()

hasattr()

max()

round()

delattr()

hash()

memoryview()

set()

object()

object() 函式返回乙個空物件。

不能向這個物件新增新的屬性或方法。

這個物件是所有類的基礎,它擁有所有類預設的內建屬性和方法。

x =

object()

print

(dir

(x))

# 返回結果

['__class__'

,'__delattr__'

,'__dir__'

,'__doc__'

,'__eq__'

,'__format__'

,'__ge__'

,'__getattribute__'

,'__gt__'

,'__hash__'

,'__init__'

,'__init_subclass__'

,'__le__'

,'__lt__'

,'__ne__'

,'__new__'

,'__reduce__'

,'__reduce_ex__'

,'__repr__'

,'__setattr__'

,'__sizeof__'

,'__str__'

,'__subclasshook__'

]

python實用的內建函式

函式 描述 dir obj 顯示物件的屬性,如果沒有提供引數,則顯示全域性變數的名字 help obj 以一種整齊美觀的形式 顯示物件的文件字串,如果沒有提供任何引數,則會進入互動式幫助。int obj 將乙個物件轉換為整數 len obj 返回物件的長度 open fn,mode 以 mode r...

實用內建函式

dir obj 顯示物件的屬性,如果沒有提供引數,則顯示全域性變數的名字 help obj 以一種整齊美觀的形式 顯示物件的文件字串,如果沒有提供任何引數,則會進入互動式幫助。int obj 將乙個物件轉換為整數 len obj 返回物件的長度 open fn,mode 以 mode r 讀,w 寫...

python重寫內建函式 python 內建函式

說明 zip 函式用於將可迭代的物件作為引數,將物件中對應的元素打包成乙個個元組,然後返回由這些元組組成的列表。如果各個迭代器的元素個數不一致,則返回列表長度與最短的物件相同,利用 號操作符,可以將元組解壓為列表。語法 zip iterable1,iterable2,引數 iterable 乙個或多...