利用 subprocess 模块
For OS X, you can use subprocess module and call 'cls' from shell:
Python
import subprocess as sp
sp.call('cls',shell=True)
|
1
2
3
|
import subprocess as sp
sp.call('cls',shell=True)
|
To prevent '0' from showing on top of the window, replace the 2nd line with:
Python
tmp = sp.call('cls',shell=True)
|
1
2
|
tmp = sp.call('cls',shell=True)
|
For linux, you must replace cls command with clear
Python
tmp = sp.call('clear',shell=True)
|
1
2
3
|
tmp = sp.call('clear',shell=True)
|
利用 os 模块
Python
import os
os.system('cls') # For Windows
os.system('clear') # For Linux/OS X
|
1
2
3
4
5
|
import os
os.system('cls') # For Windows
os.system('clear') # For Linux/OS X
|
推荐利用快捷键
ctrl + L
-
zeropython 微信公众号
5868037 QQ号
[email protected] QQ邮箱