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 运行出错
kou-dongdongmatoMacBook-Pro:python gdd$ ./test.py
what is your name?
gao
Traceback (most recent call last):
File "./test.py", line 3, in
name=input("what is your name?\n")
File "", line 1, in
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+"!")