python怎么清空shell界面
lewis
2017-10-24
23次阅读
在Python中,要清空shell界面可以使用以下两种方法。
- 使用
os.system函数调用系统命令清空shell界面。
import os
def clear():
os.system('cls' if os.name == 'nt' else 'clear')
clear()
- 使用
print函数打印特殊的控制字符\033c清空shell界面。
def clear():
print('\033c', end='')
clear()
这两种方法都可以在Windows和Unix系统上使用。

发表评论:
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。