Skip to main content
 首页 » 编程设计

python之如何使输入行低于打印行

2025年05月04日15zengkefu

这是我的:

choice = int(input("Choose an action")) - 1 

在控制台中显示如下:

Choose an action(The user input goes here) 

我想要的是:

Choose an action 
(the user input goes here) 

请您参考如下方法:

您可以打印消息,这将自动添加一个换行符:

print("Choose an action") 
choice = int(input()) - 1 

或者在输入消息的末尾手动包含一个换行符 (\n):

choice = int(input("Choose an action\n")) - 1