【问题标题】:I want to print and input in the same line in python. How can I do it?我想在 python 的同一行中打印和输入。我该怎么做?
【发布时间】:2020-06-09 09:26:42
【问题描述】:

我想在 python 的同一行中打印和输入。但我不需要打印然后多输入。 示例:我想在命令屏幕上看到它们:

Coordinates : X = 52 "<ENTER>" Y = 964 "<ENTER>" Z = 651

输入每个坐标后会按下回车键。将请求同一行的下一个坐标。

其实我是想一行一行的完成下面的操作。

print('Coordinates : X') = input() , print('Y') input(), print('Z') input()

我试过了。但我不想要它。我需要,首先 print('Coordinates X :') 然后输入一个变量。 print('Y :') 然后输入到其他变量。 print('Z:') 然后输入到另一个变量。但所有这些命令必须是同一行。

谢谢你,最好的问候!

【问题讨论】:

  • 如果您想在字符串后面加一个空格,请尝试print(your_string, end="")print(your_string, end=" ")

标签: python input printing coordinates


【解决方案1】:

你可以试试

print("Coordinates:  X = {0}, Y = {1}, Z = {2}".format(input(), input(), input()))

【讨论】:

猜你喜欢
  • 2015-10-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-01-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多