简体   繁体   English

我想在 python 的同一行中打印和输入。 我该怎么做?

[英]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.

相关问题 我想使用python中的列表理解一一打印列表中的项目。 怎么能这样做? - I want print items in list one by one using list comprehension in python. How can do that? Python:如何将打印语句和输入放在同一行? - Python: How do I put print statement and input on same line? 我想在 Python 中返回文件名。 我怎样才能正确地做到这一点? - I want to return file name in Python. How can I properly do it? 如何使用\\ r在同一行上打印Python? - How can I use \r to make Python print on the same line? 如何在 Python 的同一行上打印变量和字符串? - How can I print variable and string on same line in Python? 无法在python中的同一行上打印。 既不打印(“ string here”,end =“”),也不打印“东西” - Can not print on same line in python. Neither print(“string here”, end = “”) nor does print “something”, work 如何在同一行打印这些字符? - How do I print these characters on the same line? 我想将dataframe的值替换为python中的列名。 我应该怎么做? - I want to replace values of dataframe as a column name in python. How am I suppose to do that? 如何在同一行上打印字符? - How do I print the characters on the same line? 我想在 python 中运行小型 Julia 代码/模块。 我该怎么做? - I want to run small Julia code/modules in python. How should I do that?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM