简体   繁体   English

是否可以在没有换行符的情况下获得用户输入(多行消息)

[英]Is it Possible to get user input(multiline message)without a newline

I am taking user input and my message is a multi line string,so whenever i execute my script, a newline is printed.我正在接受用户输入,我的消息是一个多行字符串,所以每当我执行我的脚本时,都会打印一个换行符。

code:代码:

name = "name"
message_count = "count"
curr_time = "curr_time"
input_message = f"""
╔=======-{name}|{message_count}|{curr_time}
|_____
"""    
var = input(input_message)

Output: Output:

图片

i want the cursor to be on same line as the input message,is it possible in python.我希望 cursor 与输入消息在同一行,是否可以在 python 中。

Just remove the newline at the end of the string.只需删除字符串末尾的换行符即可。

input_message = f"""
╔=======-{name}|{message_count}|{curr_time}
|_____"""   

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM