清除屏幕 [英] Clearing the screen

查看:72
本文介绍了清除屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我使用IDLE在我的机器上编写Python代码。我还没有能够做b
$ b来调用一个名为clear()/ cls()/ clr()的内置函数,因为

它可能不会''存在。所以我所做的是编码我自己的函数cls()

如此

Hi i use IDLE to code Python in my machine. What i haven''t been able
to do is call an in-built function called clear()/cls()/clr() because
it mightn''t exist. so what i did is coded my own function called cls()
as such

def cls( ):
def cls():



for i in range(1,40):

print" ;


现在可以很好地完成这项工作并且我得到了清除屏幕但是我每次开始IDLE时都会想要实现它,而不需要导入

任何模块,我希望能够只做cls()并能够清除屏幕上的
。这可以实现吗?这是否意味着我必须修补一下

位内部?


谢谢。


-

欢呼,

Ishwor Gurung


for i in range(1,40):
print " ";

now that does the job very nicely and i get cleared screen but what i
really want to achieve it everytime i start IDLE, without importing
any module, i want to be able to do just cls() and be able to clear
the screen. Is that achievable? Does that have mean i have to tinker a
bit with in-builts??

Thank you.

--
cheers,
Ishwor Gurung

推荐答案

嗨Iswor,

如果我理解正确,那么你的程序正在将输出写入

控制台/终端窗口,你想要清除那个窗口。

我不知道任何库方法,但你可能会这样做:


os.system(" cls")#for windows



os.system(" clear")#for unix

虽然不是最先进的解决方案。

---

节日快乐!

~Lars

Hi Iswor,

If I understand you correctly then your program is writing output to a
console/terminal window and you want to clear that window.
I don''t know of any library methods for that, but you might just do:

os.system("cls") #for windows
or
os.system("clear") #for unix
Not the most advanced solution though.
---
Happy holidays!
~Lars


2004年12月24日15:33:26 -0800, Lars< la ****** @ lycos.com>写道:
On 24 Dec 2004 15:33:26 -0800, Lars <la******@lycos.com> wrote:
嗨Iswor,

如果我理解正确,那么你的程序正在将输出写入
控制台/终端窗口,你想清除那个窗口。
我不知道任何库方法,但你可能会这样做:


我没有做任何控制台i / o。简单一点。我正在尝试清除IDLE(用原始的

发行版分发的一个python IDE)屏幕,这非常简单但是必须要做
Hi Iswor,

If I understand you correctly then your program is writing output to a
console/terminal window and you want to clear that window.
I don''t know of any library methods for that, but you might just do:
well i am not doing any console i/o. Just simple one. i am trying to
clear the IDLE (one of python IDE distributed with the original
distribution) screen which is pretty easy but having to do
import cls
cls()
每次都很无聊(2行无聊!!)所以我想要的是

能够执行justcls()
import cls
cls() everytime is boring (2 lines of boredom!!) so what i want is to be
able to do justcls()



而且没有更多甚至更少!! ;-)

os.system(" cls")#for windows

os.system(" clear")#for unix
是啊我使用''os''模块'的system()方法,但这并不是我的意思。

虽然不是最先进的解决方案。


and nothing more or even less!! ;-)

os.system("cls") #for windows
or
os.system("clear") #for unix yeah i have used the ''os'' module''s system() method but that wasn''t what i meant.
Not the most advanced solution though.



;-) Thanx无论如何交配。


[snip]

-

欢呼,

Ishwor Gurung


;-) Thanx anyway mate.

[snip]
--
cheers,
Ishwor Gurung


在星期六,2004-12-25在07:43,Ishwor写道:
On Sat, 2004-12-25 at 07:43, Ishwor wrote:
2004年12月24日15: 33:26 - 0800,Lars< la ****** @ lycos.com>写道:
On 24 Dec 2004 15:33:26 -0800, Lars <la******@lycos.com> wrote:
嗨Iswor,

如果我理解正确,那么你的程序正在将输出写入
控制台/终端窗口,你想清除那个窗口。
我不知道任何库方法,但你可能会这样做:
我没有做任何控制台i / o。简单一点。我正在尝试清除IDLE(用原始
发行版分发的一个python IDE)屏幕,这很容易但不得不做
Hi Iswor,

If I understand you correctly then your program is writing output to a
console/terminal window and you want to clear that window.
I don''t know of any library methods for that, but you might just do:
well i am not doing any console i/o. Just simple one. i am trying to
clear the IDLE (one of python IDE distributed with the original
distribution) screen which is pretty easy but having to do


import cls
cls()
每次都很无聊(2行无聊!!)所以我想要的是
能够只做
cls()
import cls
cls() everytime is boring (2 lines of boredom!!) so what i want is to be
able to do just cls()



而且没有更多甚至更少!! ; - )


and nothing more or even less!! ;-)




假设cls.cls()完成了你的工作,只需从cls import cls''添加''

到你的pythonrc(



Assuming cls.cls() does the job for you, just add ''from cls import cls''
to your pythonrc (


这篇关于清除屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆