我输入了
x = input("enter name: ")
Print ("hey") + x
但是在编译完成后
Typeerror: unsupported operand type(s) for +: 'nonetype' and 'str'
我正在使用python 3.6.0b1。
答案 0 :(得分:0)
您正尝试将print
(None
)的返回值添加到字符串中。正确设置括号非常重要。
x = input("enter name: ")
print("hey" + x)
答案 1 :(得分:0)
print()是一个带字符串的函数调用,所以你需要将括号内的字符串传递给函数调用,如此;
x = input("enter name: ")
print ("hey " + x)
有关print()的更多信息,请访问:https://docs.python.org/3/tutorial/inputoutput.html