一个可以在Python shell里面实现刷屏的小工具

由于我是一个刷屏狂魔,在python shell里面一旦行数多了,我就眼花缭乱了,就得刷屏。以前一直是:

import os
os.system('clear')

但是我的刷屏频率太高了,输入这么多显得很累啊。于是就做了一个小工具, cs.py:

  1 import os
  2
  3 class Cls():
  4         """to clear the screen in python shell based on both linux or windows"""
  5         def __init__(self):
  6                 self.cmd = 'clear' if os.name == 'posix' else 'cls'
  7
  8         def cls(self):
  9                 os.system(self.cmd)
 10
 11 c = Cls()
 12 cls = c.cls

这样不论是windows 还是linux下的python shell, 只要:

from cs import cls
cls()

就可以实现刷屏了。哈哈。

滚动至顶部