亚洲最大看欧美片,亚洲图揄拍自拍另类图片,欧美精品v国产精品v呦,日本在线精品视频免费

  • 站長資訊網(wǎng)
    最全最豐富的資訊網(wǎng)站

    Python2.x 和 Python3.x 中 raw_input( ) 和 input( ) 區(qū)別

    1、在 Python2.x 中 raw_input( ) 和 input( ),兩個函數(shù)都存在,其中區(qū)別為:

    • raw_input( ) 將所有輸入作為字符串看待,返回字符串類型。
    • input( ) 只能接收”數(shù)字”的輸入,在對待純數(shù)字輸入時具有自己的特性,它返回所輸入的數(shù)字的類型( int, float )。

    2、在 Python3.x 中 raw_input( )input( ) 進(jìn)行了整合,去除了 raw_input( ),僅保留了 input( ) 函數(shù),其接收任意任性輸入,將所有輸入默認(rèn)為字符串處理,并返回字符串類型。

    例如:

    Python 2.3.4 (#1, Feb  2 2005, 11:44:13)   [GCC 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)] on linux2  Type "help", "copyright", "credits" or "license" for more information.  >>> user=raw_input("please input:")         please input:wei                          #  raw_input 輸入  字符串  成功  >>> user  'wei'  >>> user=input("please input:")            please input:123                          #  input 輸入  數(shù)字  成功(返回的是數(shù)字)  >>> user  123  >>> user=raw_input("please input:")  please input:111               #  raw_input 輸入  數(shù)字  成功(返回的還是當(dāng)成字符串)  >>> user  '111'  >>> user=input("please input:")  please input:wei                          #  input  輸入字符串   失敗  Traceback (most recent call last):    File "<stdin>", line 1, in ?    File "<string>", line 0, in ?  NameError: name 'wei' is not defined

    在 Python 3.2.3 中 input 和 raw_input 整合了,沒有了 raw_input:

    Python 3.2.3 (default, Apr 11 2012, 07:15:24) [MSC v.1500 32 bit (Intel)] on win  32  Type "help", "copyright", "credits" or "license" for more information.  >>> user=raw_input("please input:")                 #沒有了raw_input  Traceback (most recent call last):    File "<stdin>", line 1, in <module>  NameError: name 'raw_input' is not defined  >>> user=input("please input:")  please input:wei  >>> user  'wei'  >>> user=input("please input:")                     #input的輸出結(jié)果都是作為字符串  please input:123  >>> user  '123'

    原文地址:https://blog.csdn.net/suibianshen2012/article/details/51378948

    贊(0)
    分享到: 更多 (0)
    網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號