IDLE如何清屏?
回复内容:
有必要这么复杂吗试试
import os
os.system('cls')
只会多一个0
---------------------------
忘了说了,这个只有cmd管用,IDLE 好像不行。
为啥要用自带的idle?集成到vs和用命令行多方便。 原文链接:python idle 清屏问题的解决
在学习和使用python的过程中,少不了要与Python IDLE打交道。但使用 Python IDLE 都会遇到一个常见而又懊恼的问题——要怎么清屏?
答案是为IDLE增加一个清屏的扩展ClearWindow就可以了(在Issue 6143: IDLE中可以看到这个扩展的说明)。
下面我说说安装使用的方法。
1、下载clearwindow.py(右击-目标另存为,格式为py结尾,直接点击会打开脚本内容)。
2、拷贝clearwindow.py文件,放在Python安装目录Python XXX\Lib\idlelib下面(XXX为你的python版本)。
3、记事本打开Python XXX\Lib\idlelib目录下的config-extensions.def(IDLE扩展的配置文件), 为防止出错,你可以在打开它之前先copy一个备份 。
4、修改config-extensions.def ,在末尾添加如下内容,然后保存退出:
[ClearWindow]
enable=1
enable_editor=0
enable_shell=1
[ClearWindow_cfgBindings]
clear-window=
5、打开Python的IDLE,options选项中就可以看到增加了Clear shell window ctrl+;。
6、在IDLE输入代码,然后按Ctrl+;(是指Ctrl和;),发现刚输入代码可以被清除了。
说明:
快捷键Ctrl+;,可修改成其他键,将“clear-window=
经试验,Control换成Alter时,会启动不了IDLE,换成Shift时,快捷键不起作用,因为Shift+l,直接变成输入L了。 可以参考 python idle 清屏问题的解决 关掉重开 我也非常讨厌idle这一点,要是能像matlab那样clear,clc一句话搞定就好了,可惜我们得再去安装插件
要是不安装插件,我觉得只好这样了


pip install idlex
然后创建一个快捷方式
C:\Python3\pythonw.exe "c:\Python3\scripts\idlex.pyw"
路径按自己的实际情况替换下,就OK了
缺点:用方向键上下对已经输入的命令进行遍历时,如果有多行的输入历史,会卡在那里 为什么我的就不行呢,按照步骤做的啊?在options下面只有一个Python Configure option 谢谢, 安装完成!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











Python is suitable for data science, web development and automation tasks, while C is suitable for system programming, game development and embedded systems. Python is known for its simplicity and powerful ecosystem, while C is known for its high performance and underlying control capabilities.

Python excels in gaming and GUI development. 1) Game development uses Pygame, providing drawing, audio and other functions, which are suitable for creating 2D games. 2) GUI development can choose Tkinter or PyQt. Tkinter is simple and easy to use, PyQt has rich functions and is suitable for professional development.

Python is easier to learn and use, while C is more powerful but complex. 1. Python syntax is concise and suitable for beginners. Dynamic typing and automatic memory management make it easy to use, but may cause runtime errors. 2.C provides low-level control and advanced features, suitable for high-performance applications, but has a high learning threshold and requires manual memory and type safety management.

You can learn basic programming concepts and skills of Python within 2 hours. 1. Learn variables and data types, 2. Master control flow (conditional statements and loops), 3. Understand the definition and use of functions, 4. Quickly get started with Python programming through simple examples and code snippets.

To maximize the efficiency of learning Python in a limited time, you can use Python's datetime, time, and schedule modules. 1. The datetime module is used to record and plan learning time. 2. The time module helps to set study and rest time. 3. The schedule module automatically arranges weekly learning tasks.

Python is better than C in development efficiency, but C is higher in execution performance. 1. Python's concise syntax and rich libraries improve development efficiency. 2.C's compilation-type characteristics and hardware control improve execution performance. When making a choice, you need to weigh the development speed and execution efficiency based on project needs.

Python excels in automation, scripting, and task management. 1) Automation: File backup is realized through standard libraries such as os and shutil. 2) Script writing: Use the psutil library to monitor system resources. 3) Task management: Use the schedule library to schedule tasks. Python's ease of use and rich library support makes it the preferred tool in these areas.

Is it enough to learn Python for two hours a day? It depends on your goals and learning methods. 1) Develop a clear learning plan, 2) Select appropriate learning resources and methods, 3) Practice and review and consolidate hands-on practice and review and consolidate, and you can gradually master the basic knowledge and advanced functions of Python during this period.
