Python標準庫:內建函數callable(object),pythoncallable
如果對象object參數是可以調用的對象,就返回True;否則返回False。不過要注意的是,當一個對象是可以調用的,並不表示調用該對象時執行一定成功,但不可調用的對象去調用時一定不會成功。如果類對象是一個類對象,那麼這個類是否重載有__call__()方法來決定,如果重載有這個方法就判斷為True。
例子:
#callable()函數a = 'abc'def f(a): pass print(callable(a), callable(f))
輸出結果如下:
False True
蔡軍生 QQ:9073204 深圳
python內建函數
我也在學python,一起討論討論?
python有內建函數這個名詞那就說明也有外置函數嘍?
python的內建函數built-in function是指在標準庫standard library中的內建函數。這些函數不屬於任何類或模組,可以直接調用,可以看成python語言不可分割的一部分吧。近似於關鍵字。
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()
標準庫中其他模組內的靜態方法等不屬於內建函數。
使用者自訂擴充的函數也不屬於內建。
=============
但在其他語言、其他環境下,內建函數的具體含義不同。
內建函數在概念上並沒有唯一專指,是合成詞,最好理解為“被內建了的一些函數”...餘下全文>>