1. 程式人生 > >raw_input和input

raw_input和input

1、在 Python2.x 中 raw_input( ) 和 input( ),兩個函式都存在,其中區別為:

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

2、在 Python3.x 中 raw_input( ) 和 input( ) 進行了整合,去除了 raw_input( ),僅保留了 input( ) 函式,其接收任意任性輸入,將所有輸入預設為字串處理,並返回字串型別

 

 

摘自:http://www.runoob.com/python/python-func-raw_input.html