Python TypeError:无法连接“str”和“内置函数”或“方法”对象

Python TypeError:无法连接“str”和“内置函数”或“方法”对象,python,Python,这个代码有什么问题 def welcome(name): print "congrats! You created your first Python bank account"+ name print "Hello welcome to the Python bank Account" print"To begin please enter your name" name=raw_input welcome(name) raw_input是一个函数,因此您必须调用它才能使其工作,

这个代码有什么问题

def welcome(name):
    print "congrats! You created your first Python bank account"+ name


print "Hello welcome to the Python bank Account"
print"To begin please enter your name"
name=raw_input
welcome(name)
raw_input是一个函数,因此您必须调用它才能使其工作,并且它还接受一个可选参数,该参数在调用时打印:

name=raw_input("To begin please enter your name")
例如:

In [61]: name=raw_input("enter your name")
enter your name foo bar

In [62]: name
Out[62]: ' foo bar'
只需执行name=raw\u输入即可创建对raw\u输入的新引用,因此 实际上,您试图在函数中连接字符串和原始输入 出现错误的欢迎:

In [63]: name=raw_input

In [64]: name
Out[64]: <function raw_input>
使用原始输入而不是原始输入

原始输入是一个函数,您必须调用该函数才能返回字符串,否则它将返回函数对象。

请尝试:

name = raw_input()
原始输入是一个函数,当您想要调用时,应该使用 例如:

>>> s = raw_input('--> ')
--> Monty Python's Flying Circus
>>> s
"Monty Python's Flying Circus"

这是我们的测验吗?否则,你会向我们提供你所期望的和你实际得到的……它不会创建一个真正的银行账户