本文實例講述了Python整型運算之布爾型、標準整型、長整型操作。分享給大家供大家參考,具體如下:
#coding=utf8def 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) print ''''' 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 print ''''' 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) print'''''call the function : integerType()'''integerType()
運行結果如下圖:

PS:這里再為大家推薦幾款計算工具供大家進一步參考借鑒:
在線一元函數(方程)求解計算工具:
http://tools.VeVB.COm/jisuanqi/equ_jisuanqi
科學計算器在線使用_高級計算器在線計算:
http://tools.VeVB.COm/jisuanqi/jsqkexue
在線計算器_標準計算器:
http://tools.VeVB.COm/jisuanqi/jsq
更多關于Python相關內容感興趣的讀者可查看本站專題:《Python數學運算技巧總結》、《Python數據結構與算法教程》、《Python函數使用技巧總結》、《Python字符串操作技巧匯總》、《Python入門與進階經典教程》及《Python文件與目錄操作技巧匯總》
希望本文所述對大家Python程序設計有所幫助。
新聞熱點
疑難解答
圖片精選