国产探花免费观看_亚洲丰满少妇自慰呻吟_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()
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 黔江区| 潞西市| 裕民县| 旬邑县| 深州市| 南充市| 庆元县| 桂林市| 兴安盟| 临城县| 衡水市| 眉山市| 峨眉山市| 宜城市| 临沂市| 沈阳市| 突泉县| 鲁甸县| 河南省| 潞城市| 广宁县| 巢湖市| 丹凤县| 海盐县| 钟祥市| 眉山市| 宁城县| 高密市| 商城县| 怀集县| 江山市| 石家庄市| 葫芦岛市| 福清市| 成安县| 株洲市| 和田市| 城市| 承德市| 阿勒泰市| 富阳市|