Python2和Python3区别:input

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/fly910905/article/details/83417911

python2.x

  • 在python2.x中raw_input( )和input( ),两个函数都存在

其中区别为

  • raw_input( )---将所有输入作为字符串看待,返回字符串类型
  • input( )-----只能接收“数字”的输入,在对待纯数字输入时具有自己的特性,它返回所输入的数字的类型( int, float )

python3.x

  • 在python3.x中raw_input( )和input( )进行了整合,去除了raw_input( ),仅保留了input( )函数,
  • 其接收任意任性输入,将所有输入默认为字符串处理,并返回字符串类型。

猜你喜欢

转载自blog.csdn.net/fly910905/article/details/83417911