溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Python 極簡教程(二)編碼工具

發(fā)布時間:2020-08-11 15:08:18 來源:網絡 閱讀:208 作者:minzhung 欄目:軟件技術

Python 的編碼工具很多。目前最流行的是 pycharm,關于 pycharm 的安裝使用請參考 PyCharm安裝使用教程。

而學習過程中,我覺得最好用的,還是 Python 自帶的練習工具 IDLE。這款工具不用安裝,裝好 Python 后就有了。

這款工具最大的好處,就是變量的值、函數(shù)返回值都可以直接展示,不用打印即可查看。這極大了方便學習過程中,需要不斷的查看各種語句的執(zhí)行結果。

基本使用

打開工具,Windows 開始菜單 > 所有程序 > Python 3.6 > IDLE (Python 3.6 32-bit)
Python 極簡教程(二)編碼工具
打開后,界面如下:
Python 極簡教程(二)編碼工具

在練習過程中,如果需要創(chuàng)建 Python 文件,也可以通過 IDLE 操作:
打開File > New File 或者使用快捷鍵Ctrl + N
Python 極簡教程(二)編碼工具
在新建的窗口中輸入 Python 代碼
Python 極簡教程(二)編碼工具
然后可以運行,運行方式可以直接按 F5或者點擊菜單欄中的Run > Run Module
Python 極簡教程(二)編碼工具
運行后會彈出要求保存的提示
Python 極簡教程(二)編碼工具
點擊確定后,保存到你存放練習筆記的目錄即可。
Python 極簡教程(二)編碼工具
運行后,會回到 Python IDLE 的 shell 界面,上面顯示了你當前運行的文件名稱。你可以接下來在光標位置繼續(xù)操作。
Python 極簡教程(二)編碼工具

修改 IDLE 主題

當然我現(xiàn)在用的主題修改過,修改主題的方法如下:
打開菜單 Options > Config IDLE
Python 極簡教程(二)編碼工具

  1. 修改字體
    個人比較喜歡 DejaVu Sans Mono 這種字體,自動第一次用 ubuntu 系統(tǒng)就喜歡上了這種類似的字體??筛鶕?jù)喜好選擇對應的字體,右邊展示的是當前字體各種文字的顯示樣式。
    Python 極簡教程(二)編碼工具
  2. 修改主題樣式
    需要找到 config-highlight.cfg 文件,直接使用 windows鍵 + R 打開“運行”,在運行窗口輸入(拷貝粘貼進去即可):
    notepad %USERPROFILE%\.idlerc\config-highlight.cfg

    這句命令會用記事本打開 config-highlight.cfg 文件。
    如果沒有這個文件,則使用如下命令:

    %USERPROFILE%\.idlerc\

    該命令會進入一個文件夾,在該文件夾下新建一個文本文件,把名字修改為 config-highlight.cfg,右鍵使用記事本打開。

然后將下面的這段內容全部拷貝粘貼進去

[Obsidian]
definition-foreground = #678CB1
error-foreground = #FF0000
string-background = #293134
keyword-foreground = #93C763
normal-foreground = #E0E2E4
comment-background = #293134
hit-foreground = #E0E2E4
builtin-background = #293134
stdout-foreground = #678CB1
cursor-foreground = #E0E2E4
break-background = #293134
comment-foreground = #66747B
hilite-background = #2F393C
hilite-foreground = #E0E2E4
definition-background = #293134
stderr-background = #293134
hit-background = #000000
console-foreground = #E0E2E4
normal-background = #293134
builtin-foreground = #dd17e8
stdout-background = #293134
console-background = #293134
stderr-foreground = #FB0000
keyword-background = #293134
string-foreground = #EC7600
break-foreground = #E0E2E4
error-background = #293134

[tango]
definition-foreground = #fce94f
error-foreground = #fa8072
string-background = #2e3436
keyword-foreground = #8cc4ff
normal-foreground = #ffffff
comment-background = #2e3436
hit-foreground = #ffffff
break-foreground = #000000
builtin-background = #2e3436
stdout-foreground = #eeeeec
cursor-foreground = #fce94f
hit-background = #2e3436
comment-foreground = #73d216
hilite-background = #edd400
definition-background = #2e3436
stderr-background = #2e3436
break-background = #2e3436
console-foreground = #87ceeb
normal-background = #2e3436
builtin-foreground = #ad7fa8
stdout-background = #2e3436
console-background = #2e3436
stderr-foreground = #ff3e40
keyword-background = #2e3436
string-foreground = #e9b96e
hilite-foreground = #2e3436
error-background = #2e3436

如下圖:
Python 極簡教程(二)編碼工具
拷貝進去后,保存并關閉。

關閉 IDLE 重新打開,進入剛才的設置界面,點擊 Highlights,選擇剛才配置的主題 Obsidiantango。
Python 極簡教程(二)編碼工具

然后愉快的編碼吧,好看的字體和配色也會讓自己學習的興趣增加不少!

其余的編碼工具包括 Sublime text、Eclipse 等,請參考其他網上教程。

下一篇 數(shù)據(jù)類型

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經查實,將立刻刪除涉嫌侵權內容。

AI