对于python用户而言,2.x和3.x版本在使用上有大量不同,而关于最常用的input和raw_input函数存在一些区别。
input 用于整形和浮点数的输入
raw_input更多的强调字符串的输入
而python本身也在慢慢靠近3.x版本,所以在2.x中所用的raw_input在3.x版本中已经被取消
比如在3.x版本中使用raw_input就会报错
Traceback (most recent call last):
File "C:/Users/王蔚峻/AppData/Local/Programs/Python/Python35-32/test.py", line 8, in <module>
guess = int(raw_input('please input your guess:'))
NameError: name 'raw_input' is not defined