Python数字
来源:互联网 发布:多开分身软件 编辑:程序博客网 时间:2024/05/16 14:28
1. 数字工厂函数
- bool(obj)
- int(obj, base=10)
- long(obj, base=10)
- float(obj)
- complex(str)
- complex(real, imag=0.0)
2. 内建数值函数
- abs(num)
- coerce(num1, num2)
- divmod(num1, num3)
- pow(num1, num2, mod=1)
- round(flt, ndig=0)
>>> abs(-1)1>>> abs(1+1j)1.4142135623730951>>> coerce(1.3, 1)(1.3, 1.0)>>> coerce(1, 2L)(1L, 2L)>>> divmod(10, 3)(3, 1)>>> divmod(-10, 3)(-4, 2)>>> pow(2, 5)32>>> pow(5, 2)25>>> round(3.567)4.0>>> round(3.567, 2)3.57
2.1 仅用于整数的函数
- hex(num)
- oct(num)
- chr(num)
- ord(chr)
- unichr(num)
>>> oct(255)'0377'>>> hex(255)'0xff'>>> chr(97)'a'>>> ord('b')98 >>> unichr(0x4e00)u'\u4e00'>>> print unichr(0x4e00)一
0 0
- python 数字
- 【python】-数字
- Python 数字
- Python数字
- Python数字
- Python数字
- Python 数字
- Python -- 数字
- Python数字
- Python数字
- Python数字
- Python-数字
- Python数字
- Python数字
- Python 数字
- python-数字
- python数字
- python数字
- 栈实现的带括号的计算器
- Delete a node, only give access to that node.
- js 识别or 手机
- Kali进行web渗透笔记(一)
- MJExtension 框架的使用
- Python数字
- PHP图片上传时$_FILES为空解决
- Microsoft Windows远程桌面协议中间人攻击漏洞(CVE-2005-1794)解决方案
- CALayer学习
- Android通过ViewPager实现Tab面板实例
- centos6.3配置MFS服务器
- 华为机试题,字符串最后一个单词的长度
- 代码训练营——File,列出指定目录下的所有内容
- Kali进行web渗透笔记(二)