后浪云Python教程:python idle怎么清屏

在学习和使用python 写代码时(据说高手都用IDLE写代码的),少不了要与Python IDLE打交道。但使用 Python IDLE 都会遇到一个常见而又懊恼的问题:不能清屏?

后浪云Python教程:python idle怎么清屏插图

下载clearwindow.py(http://pan.baidu.com/s/1ntOzSAt)(文件原作者:Roger D. Serwy)

复制clearwindow.py文件,并放在Python安装目录PythonX\Lib\idlelib下面(我用的是python3.4.3所以路径是:Python34\Lib\idlelib)

后浪云Python教程:python idle怎么清屏插图1

在Python X\Lib\idlelib目录下找到config-extensions.def(IDLE扩展的配置文件),用记事本打开

后浪云Python教程:python idle怎么清屏插图2

在文件末尾添加如下代码:

[ClearWindow]

enable=1

enable_editor=0

enable_shell=1

[ClearWindow_cfgBindings]

clear-window=<Control-Key-l>

后浪云Python教程:python idle怎么清屏插图3

打开Python的IDLE,options选项中就可以看到增加了Clear shell window ctrl L

后浪云Python教程:python idle怎么清屏插图4

在IDLE输入代码,然后按Ctrl+L;(是指Ctrl和L),发现刚输入代码可以被清除了

后浪云Python教程:python idle怎么清屏插图5

后浪云Python教程:python idle怎么清屏插图6

THE END