2.0 python內建函數 原

在ipython下查看python內建函數_builtin_. \tab補全可以查看

可以到python官網上去查看 https://docs.python.org/2.7/

abs(number) \\\返回數字絕對值
max(interable,\[,key=func\])
min(interable,\[,key=func\]) \\\返回最大(最小)值
max('123')返回3 max(\[1,2,3\])返回3
max('123a','231')會返回長的字符串
len() 返回字符串長度
divmod() 返回兩個數的商和餘數
pow(x, y, z=None) x的y次方,然後對z取餘
round(number, ndigits=None) 經number變爲浮點數,ndigits決定保留小數位數,默認爲0
callable()返回bool,判斷參數是否爲可調用對象
type() 輸出參數類型
isinstance(p\_object, class\_or\_type\_or_tuple) //返回bool,判斷參數是否爲指定類型(可以將多個類型放在tuple中,只要屬於tuple中的類型就會返回True)
cmp() 判斷字符大小(應該是按ASCII碼排序),先比第一個然後,不比較字符串長度
range(start=None, stop=None, step=None)
int() 數據類型轉換
float()
long()
complex()
str() 
list()
hex(number) ->str 把一個整數傳化成16進制的字符串
int()可以將其它進制轉化爲10進制
oct(number) ->str 把一個整數轉化成8進制的字符串
eval(source, globals=None, locals=None) 將字符串轉化有效表達式
chr() 返回ASCII碼對應字符
ord() 返回字符對應的ASCII碼
str.capitalisze() 字符串的方法,將字符串首字母大寫,若首字符不是字母,則會返回原字符串
str.replace(self, old, new, count=None) \\\替換字符串的字符
str.split(self, sep=None, maxsplit=None) \\\切分字符串,默認按空格、tab(\\tb)、換行符(\\n)切分,返回列表;
str.join(iterable) 將可迭代對象的元素以指定字符串連接,並返回字符串

string 模塊
string.lowercase
string.uppercase \\\打印大寫字母

filter(function_or_none, sequence)  \\按照function對後面的序列進行過濾,將後面的序列傳入前面的參數,如果返回True則返回序列元素

zip(seq1, seq2, *more_seqs) \\ 將多個序列合併爲一個大的序列,序列長度不一致時會取最短的序列長度
	"""
	zip(seq1 [, seq2 [...]]) -> [(seq1[0], seq2[0] ...), (...)]
	
	Return a list of tuples, where each tuple contains the i-th element
	from each of the argument sequences.  The returned list is truncated
	in length to the length of the shortest argument sequence.
	"""

map(function, sequence, *sequence_1) \\和zip類似,但會多一步對序列的元素按照function進行處理
	"""
	map(function, sequence[, sequence, ...]) -> list

	Return a list of the results of applying the function to the items of
	the argument sequence(s).  If more than one sequence is given, the
	function is called with an argument list consisting of the corresponding
	item of each sequence, substituting None for missing values when not all
	sequences have the same length.  If the function is None, return a list of
	the items of the sequence (or a list of tuples if more than one sequence).
	"""
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章