国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

python數字類型介紹以及創建數字值對象引用、刪除數字值引用操作實例

2019-11-08 01:30:13
字體:
來源:轉載
供稿:網友
#coding=utf8'''數字類型:數字提供標量貯存和直接訪問。它是不可更改類型,變更數字的值會產生新的對象。Python支持多種數字類型:整型、長整型、布爾型、雙精度浮點型、十進制浮點型和復數。'''def digtalIndroduce():    ''' 創建數值對象并給其賦值 '''    PRint "The first give the variable to value"    Int=45    Long=4444444444444L    Bool=True    Float=3.141592653589793228885555558888    Dicmal=10.25    Complex=25+12.36j         print "%d the id:%r"   %(Int,id(Int))    print "%r the id:%r"   %(Long,id(Long))    print "%r the id:%r"   %(Bool,id(Bool))    print "%r the id:%r"   %(Float,id(Float))    print "%r the id:%r"   %(Dicmal,id(Dicmal))    print "%r the id:%r"   %(Complex,id(Complex))    '''     更新數字對象:    通過給數字對象重新賦值,可以“更新”一個數值對象。    所謂的更新,其實就是生成一個新的數值對象,并得到它的引用。    '''    print "Update  the value of the variable"    Int+=5    Long=4444L    Bool=False    Float=3.14188    Dicmal+=10.25    Complex=10+12j         print "%d the id:%r"   %(Int,id(Int))    print "%r the id:%r"   %(Long,id(Long))    print "%r the id:%r"   %(Bool,id(Bool))    print "%r the id:%r"   %(Float,id(Float))    print "%rthe id:%r"   %(Dicmal,id(Dicmal))    print "%r the id:%r"   %(Complex,id(Complex))        '''     刪除數字對象:    Python無法真正刪除一個數值對象,僅僅刪除數值對象的一個引用。    刪除對象的引用之后,就不可以再使用這個引用(變量名),除非重新賦值。    否則使用刪除的引用,會引發NameError異常。    '''    print "delete the object reference"    del Int,Long,Bool,Float,Dicmal,Complex    try:        print "%d the id:%r"   %(Int,id(Int))        print "%r the id:%r"   %(Long,id(Long))        print "%r the id:%r"   %(Bool,id(Bool))        print "%r the id:%r"   %(Float,id(Float))        print "%rthe id:%r"   %(Dicmal,id(Dicmal))        print "%r the id:%r"   %(Complex,id(Complex))    except NameError,e:        print "NameError:",e        '''call the function :digtalIndroduce()'''digtalIndroduce()
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 泾源县| 万年县| 尉氏县| 永宁县| 确山县| 陇西县| 宜城市| 巴中市| 太仆寺旗| 阳西县| 海晏县| 嵊州市| 衡阳市| 利川市| 剑河县| 寿光市| 乳山市| 梁平县| 石渠县| 新郑市| 亳州市| 红桥区| 郴州市| 桓仁| 宁乡县| 斗六市| 浦县| 霍山县| 蒙自县| 上杭县| 阳山县| 临颍县| 德安县| 昆明市| 霍邱县| 礼泉县| 黄冈市| 紫云| 邓州市| 松滋市| 新干县|