>>> input ("my age is : ")
my age is :23
23
>>> raw_input("my age is : ")
my age is : 23
'23'
有什么不一样?再看一个例子
>>> age = input(" how old r u ?")
how old r u ?23
>>> print "you are " + age + "!"
Traceback (most recent call last):
File "<pyshell#20>", line 1, in <module>
print "you are " + age + "!"
TypeError: cannot concatenate 'str' and 'int' objects
>>> age = raw_input("how old r u? ")
how old r u? 23
>>> print "you are " + age +"!"
you are 23!
input()是把读入的数据默认为Python expression(额...中文怎么说,python表达式?)
raw_input()是把读入的数据转换成String.
所以一般时候我们用来接受用户输入的时候,都是使用raw_input()而非input().