这里有新鲜出炉的Python多线程编程,程序狗速度看过来!
Python 是一种面向对象、解释型计算机程序设计语言,由Guido van Rossum于1989年底发明,第一个公开发行版发行于1991年。Python语法简洁而清晰,具有丰富和强大的类库。它常被昵称为胶水语言,它能够把用其他语言制作的各种模块(尤其是C/C++)很轻松地联结在一起。
这篇文章主要介绍了Python整型运算之布尔型、标准整型、长整型操作,结合具体实例形式分析了Python中布尔型、标准整型、长整型等相关运算技巧,代码备有详尽注释,需要的朋友可以参考下
本文实例讲述了Python整型运算之布尔型、标准整型、长整型操作。分享给大家供大家参考,具体如下:
- #coding=utf8
- def integerType():
- '''''
- 布尔型:
- 该值的取值范围只有两个值:True(1)、False(0)
- '''
- Tbool=True
- Fbool=False
- print "The True is stand for %d" %(Tbool)
- print "The False is stand for %d" %(Fbool)
- '''''
- python标准整数类型:
- Python标准整数类型是最通用的数字类型。
- 在大多数32位机器上,标准整数类型的取值范围:-2147483648 到 2147483647
- Python标准整数类型等价于C的有符号长整型。
- 八进制整数以数字“0”开始。
- 十六进制整数以“0x”或“0X”开始
- '''
- bInt=010101
- dInt=84455555
- oInt=075
- hInt=0xabc
- print "The binary of the standard integer:",bInt
- print "The decimal of the standard integer:",dInt
- print "The octal of the standard integer:",oInt
- print "The hexadecimal of the standard integer:",hInt
- '''''
- python长整型:
- Python长整型能表达的数值仅仅与机器值的(虚拟)内存大小有关。
- 长整数类型是标准整数类型的超集。
- 在一个整数值后面加上个L(大写或小写都可以,推荐使用大写,避免和数字1混淆),表示这个整数时长整数。
- 这个整数可以是十进制、八进制、十六进制。
- 只有对长整数调用repr()才有机会看到L,对长整数调用str()看不到L。
- 整型和长整型正在统一为一种。
- '''
- bLong=0111111111111111111111111111111111111111111111L
- dLong=8888888888888888888888888888888888888888888888L
- oLong=0777777777777777777777777777777777777777777777L
- hLong=0XFFFFFFFFFFFFFFFFFAAAAAAAAAAAAABBBBBBBBBB78L
- print "The binary of the long integer:",repr(bLong)
- print "The decimal of the long integer:",repr(dLong)
- print "The octal of the long integer:",repr(oLong)
- print "The hexadecimal of the long integer:",repr(hLong)
- '''''call the function : integerType()'''
- integerType()
运行结果如下图:
PS:这里再为大家推荐几款计算工具供大家进一步参考借鉴:
希望本文所述对大家Python程序设计有所帮助。
来源: http://www.phperz.com/article/17/1027/351165.html