[英]How can I clear console but leave needed print-line?
For example I have code:例如我有代码:
print("Your status - online")
while(True):
print("Searching for server")
And I need to clear console, but leave "Your status - online", so "Searching for server" isn't overlapping.我需要清除控制台,但保留“您的状态 - 在线”,因此“搜索服务器”不会重叠。
You can use a carriage return to get back to the beginning of the line.您可以使用回车返回到行首。 Then, when you print, it overrides the previously printed line.然后,当您打印时,它会覆盖先前打印的行。
print("Your status - online")
while True:
print("Searching for server", end="\r")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.