Blogger Information
Blog 12
fans 0
comment 0
visits 11998
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
Python常用数据类型语法
張涛的博客
Original
826 people have browsed it

1.int类型

    int类型的数据是没有长度限制的,它的最大长度只与计算机的内存有关。

1 bin(i)    返回二进制表示结果
2 hex(i)    十六进制
3 int(i)    整数(如果i是浮点数就会放回其整数部分)
4 oct(i)    八进制
5 int(s,base)    将字符串转换成整数,幂可以用**实现(10**5)。内置的float与str类型都支持到整数的转换
6 chr()    将数字转换成字符
7 ord()    将字符转换成ASCII码
8 round()    函数对值进行四舍五入。整数和浮点型相加结果是浮点型

2.简单比较两个float是否相等

    def equal_float(a, b):
        return abs(a-b)<=sys.float_info.epsilon


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post