1. 程式人生 > >Python2和Python3區別:input

Python2和Python3區別:input

python2.x

  • 在python2.x中raw_input( )和input( ),兩個函式都存在

其中區別為

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

python3.x

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