简体   繁体   English

在PyScripter中清除屏幕的命令?

[英]Command to clean screen in PyScripter?

Is there a single command to clean the screen of the Python Interpreter every time one runs a code in PyScripter? 每次在PyScripter中运行代码时,是否只有一个命令来清理Python解释器的屏幕?

thanks, 谢谢,

Goto pyscripter menus and check the box for clear output before run. 转到pyscripter菜单并在运行前选中清除输出框。 Tools>Options > IDE options > Python interpreter > Clear output before run. 工具>选项> IDE选项> Python解释器>运行前清除输出。

Very useful in interactive sessions. 在交互式会话中非常有用。

import os #top of script`
os.system('cls') #call whenever you want to clear terminal
import os
os.system('cls' if os.name=='nt' else 'clear')

or as suggested by jadkik94: 或者按照jadkik94的建议:

import subprocess
subprocess.call('cls' if os.name=='nt' else 'clear', shell=True)

UPDATE UPDATE

I now understand that you are trying to clear the interpreter screen in the IDE application "PyScripter". 我现在明白你正在尝试清除IDE应用程序“PyScripter”中的解释器屏幕。 I don't have any experience with this IDE, but usually IDE's are meant for developing and not for actual deployment, so if this is part of the application, and you ant to see that it's running correctly, you should run it in a command/console window and use the methods I posted here by me and others. 我对这个IDE没有任何经验,但通常IDE是用于开发而不是用于实际部署,所以如果这是应用程序的一部分,并且你看到它正在运行,你应该在命令中运行它/ console窗口并使用我和其他人发布的方法。

If you just want to create a "clean" window, but don't mind if it's actually cleared the console or not you can do something like this: 如果你只想创建一个“干净”的窗口,但不介意它是否真的清除了控制台,你可以这样做:

print "\n" * 100

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM