[英]I want to print and input in the same line in python. How can I do it?
I want to print and input in the same line in python.我想在 python 的同一行中打印和输入。 But I don't need a print then multi input.但我不需要打印然后多输入。 Example: I want to see them on the command screen:示例:我想在命令屏幕上看到它们:
Coordinates: X = 52 "<ENTER>" Y = 964 "<ENTER>" Z = 651
Enter key will be pressed after entering each coordinate.输入每个坐标后按回车键。 will request the next coordinate on the same line.将请求同一行的下一个坐标。
Actually, I want the following operations to be done in one line.实际上,我希望在一行中完成以下操作。
print('Coordinates: X') = input(), print('Y') input(), print('Z') input()
i tried it.我尝试过这个。 But i don't want it.但我不想要它。 I need, firstly print('Coordinates X:') then input to a variable.我需要,首先 print('Coordinates X:') 然后输入一个变量。 print('Y:') then input to other variable. print('Y:') 然后输入到其他变量。 print('Z:') then input to another varible. print('Z:') 然后输入到另一个变量。 but all this commands must be same line.但所有这些命令必须是同一行。
Thank you, Best Regards!谢谢您最好的问候!
You can try something like你可以尝试类似的东西
print("Coordinates: X = {0}, Y = {1}, Z = {2}".format(input(), input(), input()))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.