在Python3中,有没有一种方法可以将多个参数放入input()中?

在Python3中,有没有一种方法可以将多个参数放入input()中?,python,python-3.x,input,Python,Python 3.x,Input,例如,在print()。有没有一种方法可以像input('String',variable,'other String')那样执行类似的操作,并让它像print()那样打印提示?使用字符串插值: k = 1 v = "house" c = "yep." input(f"Do you own {k} {v}? If so, answer {c}") 如需提示: Do you own 1 house? If so, answer yep. 对于相同的输出,也可以使用旧式字符串格式: input

例如,在
print()。有没有一种方法可以像
input('String',variable,'other String')
那样执行类似的操作,并让它像
print()
那样打印提示?

使用字符串插值:

k = 1
v = "house"
c = "yep."

input(f"Do you own {k} {v}? If so, answer {c}")
如需提示:

Do you own 1 house? If so, answer yep.
对于相同的输出,也可以使用旧式字符串格式:

input ("Do you own {} {}? If so, answer {}".format( k,v,c ))

使用字符串插值:

k = 1
v = "house"
c = "yep."

input(f"Do you own {k} {v}? If so, answer {c}")
如需提示:

Do you own 1 house? If so, answer yep.
对于相同的输出,也可以使用旧式字符串格式:

input ("Do you own {} {}? If so, answer {}".format( k,v,c ))

input
函数不支持多个参数。但你可以把它包起来,自己做

>>> def multi_input(*args):
...     return input(' '.join(args))
... 
>>> var = 'your'
>>> multi_input('what is', var, 'name :')
what is your name :Shiplu
'Shiplu'

input
函数不支持多个参数。但你可以把它包起来,自己做

>>> def multi_input(*args):
...     return input(' '.join(args))
... 
>>> var = 'your'
>>> multi_input('what is', var, 'name :')
what is your name :Shiplu
'Shiplu'

另一种方法是使用
print()
end
参数,使用
input()
而不使用任何参数,例如:

print('a', 'b', 'c', end='')
input()

另一种方法是使用
print()
end
参数,使用
input()
而不使用任何参数,例如:

print('a', 'b', 'c', end='')
input()
否:。当然,您可以简单地将这些值连接成一个字符串…否:。当然,您可以简单地将这些值连接成一个字符串…