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).
	"""

猜你喜欢

转载自my.oschina.net/u/4030294/blog/2966542