bl双性强迫侵犯h_国产在线观看人成激情视频_蜜芽188_被诱拐的少孩全彩啪啪漫画

python如何清理shell中的代碼

這篇文章將為大家詳細(xì)講解有關(guān)python如何清理shell中的代碼,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。

創(chuàng)新互聯(lián)專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于網(wǎng)站制作、成都網(wǎng)站建設(shè)、康樂網(wǎng)絡(luò)推廣、重慶小程序開發(fā)公司、康樂網(wǎng)絡(luò)營銷、康樂企業(yè)策劃、康樂品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運營等,從售前售中售后,我們都將竭誠為您服務(wù),您的肯定,是我們最大的嘉獎;創(chuàng)新互聯(lián)為所有大學(xué)生創(chuàng)業(yè)者提供康樂建站搭建服務(wù),24小時服務(wù)熱線:18982081108,官方網(wǎng)址:vcdvsql.cn

python shell是Python的命令行。

交互模式下使用Python很方便,如果想清除顯示過的信息,有兩種方法可以采用。

方法一、針對Python命令行(python shell)

直接使用下面的代碼即可清理shell中的代碼:

>>>import os
>>>n = os.system('cls')

os.system('cls'),調(diào)用DOS系統(tǒng)提供的cls命令,成功則返回0。

方法二、針對IDLE Shell

1、在Python X\Lib\idlelib目錄下創(chuàng)建ClearWindow.py(其中X是Python版本號)

class ClearWindow:
    menudefs = [
        ('options', [None,
                     ('Clear Shell Window', '<<clear-window>>'),
                     ]), ]
 
    def __init__(self, editwin):
        self.editwin = editwin
        self.text = self.editwin.text
        self.text.bind("<<clear-window>>", self.clear_window2)
 
        self.text.bind("<<undo>>", self.undo_event)  # add="+" doesn't work
 
    def undo_event(self, event):
        text = self.text
 
        text.mark_set("iomark2", "iomark")
        text.mark_set("insert2", "insert")
        self.editwin.undo.undo_event(event)
 
        # fix iomark and insert
        text.mark_set("iomark", "iomark2")
        text.mark_set("insert", "insert2")
        text.mark_unset("iomark2")
        text.mark_unset("insert2")
 
    def clear_window2(self, event):  # Alternative method
        # work around the ModifiedUndoDelegator
        text = self.text
        text.undo_block_start()
        text.mark_set("iomark2", "iomark")
        text.mark_set("iomark", 1.0)
        text.delete(1.0, "iomark2 linestart")
        text.mark_set("iomark", "iomark2")
        text.mark_unset("iomark2")
        text.undo_block_stop()
        if self.text.compare('insert', '<', 'iomark'):
            self.text.mark_set('insert', 'end-1c')
        self.editwin.set_line_and_column()
 
    def clear_window(self, event):
        # remove undo delegator
        undo = self.editwin.undo
        self.editwin.per.removefilter(undo)
 
        # clear the window, but preserve current command
        self.text.delete(1.0, "iomark linestart")
        if self.text.compare('insert', '<', 'iomark'):
            self.text.mark_set('insert', 'end-1c')
        self.editwin.set_line_and_column()
 
        # restore undo delegator
        self.editwin.per.insertfilter(undo)

2、 在Python X\Lib\idlelib目錄下編輯config-extensions.def(IDLE擴(kuò)展配置文件)

添加紅色框里的內(nèi)容,其中“w”可以根據(jù)自己喜好進(jìn)行修改,必須是小寫字母。 

python如何清理shell中的代碼

此時,啟動Python IDLE,在Options菜單下會出現(xiàn)"Clear Shell Window Ctrl+W",點擊即可清屏。

關(guān)于python如何清理shell中的代碼就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學(xué)到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。

本文題目:python如何清理shell中的代碼
當(dāng)前路徑:http://vcdvsql.cn/article8/jhiiip.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供面包屑導(dǎo)航網(wǎng)站建設(shè)外貿(mào)建站建站公司電子商務(wù)關(guān)鍵詞優(yōu)化

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都app開發(fā)公司