简体   繁体   English

Python - 清除屏幕的最快方法?

[英]Python - Fastest way to clear the screen?

What would the fastest way to clear the screen, be?清除屏幕的最快方法是什么?

I've tried many solutions, they seem to work, however, I need the fastest way.我尝试了很多解决方案,它们似乎有效,但是,我需要最快的方法。 Could anyone point me in the right direction?有人能指出我正确的方向吗?

The screen, in my case, is a command prompt.就我而言,屏幕是命令提示符。

I've edited my question for better understandings.我已经编辑了我的问题以获得更好的理解。

Any help welcomed :)欢迎任何帮助:)

One portable solution could be:一种便携式解决方案可能是:

def clear_sceen():
    os.system('cls' if os.name == 'nt' else 'clear')

Another possible way would be using:另一种可能的方法是使用:

print(chr(27) + "[2J")

Although this one wouldn't be really a portable solution虽然这不是一个真正的便携式解决方案

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

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