您所在位置:网站首页 > 海量文档
 > 计算机 > Python
运维必备Python基础入门到精通.pdf29页
本文档一共被下载:次,您可全文免费在线阅读后下载本文档。
下载提示
1.本站不保证该用户上传的文档完整性,不预览、不比对内容而直接下载产生的反悔问题本站不予受理。
2.该文档所得收入(下载+内容+预览三)归上传者、原创者。
3.登录后可充值,立即自动返金币,充值渠道很便利
运维必备Python基础入门到精
通
视频课程汇总
Python函数中文手册
函数列表
1、取绝对值
abs(x)
Returntheabsolutevalue ofanumber.Theargumentmaybeaplainorlong
integerorafloating pointnumber.Ifthe argument isacomplex number,its
magnitudeisreturned.
如果你不知道绝对值什么意思,那就要补一下小学数学了!
基本用法
2
all(iterable)
ReturnTrue ifallelementsofthe iterablearetrue (orifthe iterableisempty).
Equivalentto:
3
any(iterable)
ReturnTrue ifanyelementofthe iterableistrue.Ifthe iterableisempty, return
False.Equivalentto:
4
basestring()
This abstract type is the superclass for str an unicode. It cannot be calle or
instantiate , but it can be use to test whether an object is an instance of str or
unicode.isinstance(obj,basestring)isequivalentto isinstance(obj,(str, unicode)).
是字符串和字符编码的超类 ,是抽象类型。不能被调用或者实例化。可以用来判断实例是否
为字符串或者字符编码。
5、二进制转换
bin(x)
Convertanintegernumberto a binarystring.The resultisavali Python
expression.Ifx isnota Pythonintobject,ithasto definean__index__() metho
that returnsan integer.
转换成二进制表达
方法:
6、布尔类型
bool([x])
Convertavaluetoa Boolean,usingthe standar truthtesting procedure.Ifx is
falseoromitted,this returnsFalse;otherwiseitreturnsTrue.boolisalsoaclass,
which isasubclassof int.Class boolcannot besubclasse further.Itsonly
instancesare Falsean True
布尔类型的转化
用法:
7、二进制数组的转化
bytearray([source[,encoding[,errors]]])
Returna new arrayof bytes.The bytearray typeisa mutablesequenceof integers
inthe range0 <=x <256.It hasmostofthe usualmethodsof mutable
sequences,describe in MutableSequenceTypes,aswell as mostmethodsthat
the strtype has,seeString Methods.
The optionalsource parametercan beuse to initializethe array inafew different
ways:
If itisastring,you mustalsogivetheencoding (an optionally,
errors) parameters; bytearray()then convertsthe stringto bytes
usingstr.encode().
If itisaninteger,thearraywill havethat sizean will beinit
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
用户名:
验证码:
匿名?
发表评论