python3.2 input字符串问题

python3.2 没有raw_input函数


name=input("what is your name?\n")
print("Hello,"+name+"!")

在python编译器中运行木有问题
但是保存成.py文件 chmod a+x *.py
test.py


#!/usr/bin/python
name=input("what is your name?\n")
print("Hello,"+name+"!")

./test.py 运行出错

<!-- lang: shell -->
kou-dongdongmatoMacBook-Pro:python gdd$ ./test.py 
what is your name?
gao
Traceback (most recent call last):
  File "./test.py", line 3, in <module>
    name=input("what is your name?\n")
  File "<string>", line 1, in <module>
NameError: name 'gao' is not defined

解决方法:1、输入name字符串是加上双引号 “gao”

2、改成低版本python


#!/usr/bin/python2.6

name=raw_input("what is your name?\n")
print("Hello,"+name+"!")

你可能感兴趣的:(python,input,raw_input)