如何在python输入中使用两个参数?

如何在python输入中使用两个参数?,python,python-3.x,input,Python,Python 3.x,Input,这是我的代码: name=input('whats your name? ') print('ok', name,'lest go') speak=input(name, '=>') 这是我的错误 whats your name? hossein ok hossein lest go Traceback (most recent call last): File "/home/hossein/Desktop/test.py", line 3, in <mod

这是我的代码:

name=input('whats your name? ')
print('ok', name,'lest go')
speak=input(name, '=>')
这是我的错误

whats your name? hossein
ok hossein lest go
Traceback (most recent call last):
  File "/home/hossein/Desktop/test.py", line 3, in <module>
    speak=input(name, '=>')
TypeError: input expected at most 1 argument, got 2
你叫什么名字?侯赛因
好的,侯赛因,我要走了
回溯(最近一次呼叫最后一次):
文件“/home/hossein/Desktop/test.py”,第3行,在
speak=输入(名称“=>”)
TypeError:输入最多需要1个参数,得到2个
为什么我不能在输入中使用
name
以及如何修复它。我希望它像
speak=input(name,'=>)
=>
hossein=>

谢谢

Do
speak=input(name+“=>”)
-变量和字符串将被连接。

输入([prompt])函数只接受一个参数。如果存在prompt参数,则将其写入标准输出,而不带尾随换行符。然后,函数从输入中读取一行,将其转换为字符串(去掉尾随的换行符),并返回该字符串。 但您可以在输入中连接所需的字符串,例如:

>>s=input('-->'))
-->巨蟒飞行马戏团
>>>
“巨蟒飞行马戏团”

>>>s2=输入('-->'+s+'-'))
-->巨蟒飞行马戏团-
>>>s2
“巨蟒飞行马戏团-我的新输入”

python中字符串的连接是通过使用
+
而不是
@maha是的,谢谢。它解决了hanks@obsoleteawareproducte。您的答案解决了我的问题