新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
創(chuàng)新互聯(lián)Python教程:python的內建函數(shù)在哪里
Python針對眾多的類型,提供了眾多的內建函數(shù)來處理(內建是相對于導入import來說的,后面學習到包package時,將會介紹),

網(wǎng)站建設哪家好,找創(chuàng)新互聯(lián)!專注于網(wǎng)頁設計、網(wǎng)站建設、微信開發(fā)、成都微信小程序、集團企業(yè)網(wǎng)站建設等服務項目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了柳江免費建站歡迎大家使用!
這些內建函數(shù)功用在于其往往可對多種類型對象進行類似的操作,即多種類型對象的共有的操作;如果某種操作只對特殊的某一類對象可
行,Python常將其設置為該種類型的方法(method),在后邊的內容將會接觸到
python中內置了很多函數(shù),這些函數(shù)實現(xiàn)了很多的功能。
比如,我們在用math模塊,但是不知道這個模塊下是否有自己常用的函數(shù),那么如何做呢?
方法一
import math dir(math)
學習python,盡在python學習網(wǎng)!
首先,我們導入這個模塊,使用dir函數(shù),就可以看到,這個模塊下都有哪些函數(shù)。
['__doc__', '__loader__', '__name__', '__package__', '__spec__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'copysign', 'cos', 'cosh', 'degrees', 'e', 'erf', 'erfc', 'exp', 'expm1', 'fabs', 'factorial', 'floor', 'fmod', 'frexp', 'fsum', 'gamma', 'gcd', 'hypot', 'inf', 'isclose', 'isfinite', 'isinf', 'isnan', 'ldexp', 'lgamma', 'log', 'log10', 'log1p', 'log2', 'modf', 'nan', 'pi', 'pow', 'radians', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'tau', 'trunc']
這種方法是得到一個函數(shù)列表,當然,這里還可以使用help函數(shù):
import math help(math)
如果還是對函數(shù)不是特別了解,可以到方法的文件中去看函數(shù)的定義,利用***.__file__查看位置,然后打開后綴名為.py的文件。
import random random.__file__
當前題目:創(chuàng)新互聯(lián)Python教程:python的內建函數(shù)在哪里
分享URL:http://m.fisionsoft.com.cn/article/coessjh.html


咨詢
建站咨詢
