Python 的編碼工具很多。目前最流行的是 pycharm,關(guān)于 pycharm 的安裝使用請參考 PyCharm安裝使用教程。
而學(xué)習(xí)過程中,我覺得最好用的,還是 Python 自帶的練習(xí)工具 IDLE。這款工具不用安裝,裝好 Python 后就有了。
這款工具最大的好處,就是變量的值、函數(shù)返回值都可以直接展示,不用打印即可查看。這極大了方便學(xué)習(xí)過程中,需要不斷的查看各種語句的執(zhí)行結(jié)果。
基本使用
打開工具,Windows 開始菜單 > 所有程序 > Python 3.6 > IDLE (Python 3.6 32-bit)

打開后,界面如下:

在練習(xí)過程中,如果需要創(chuàng)建 Python 文件,也可以通過 IDLE 操作:
打開File > New File 或者使用快捷鍵Ctrl + N

在新建的窗口中輸入 Python 代碼

然后可以運行,運行方式可以直接按
F5或者點擊菜單欄中的Run > Run Module
運行后會彈出要求保存的提示

點擊確定后,保存到你存放練習(xí)筆記的目錄即可。

運行后,會回到 Python IDLE 的 shell 界面,上面顯示了你當(dāng)前運行的文件名稱。你可以接下來在光標(biāo)位置繼續(xù)操作。

修改 IDLE 主題
當(dāng)然我現(xiàn)在用的主題修改過,修改主題的方法如下:
打開菜單 Options > Config IDLE

-
修改字體
個人比較喜歡 DejaVu Sans Mono 這種字體,自動第一次用 ubuntu 系統(tǒng)就喜歡上了這種類似的字體。可根據(jù)喜好選擇對應(yīng)的字體,右邊展示的是當(dāng)前字體各種文字的顯示樣式。
修改字體 - 修改主題樣式
需要找到config-highlight.cfg文件,直接使用windows鍵 + R打開“運行”,在運行窗口輸入(拷貝粘貼進去即可):
notepad %USERPROFILE%\.idlerc\config-highlight.cfg
這句命令會用記事本打開 config-highlight.cfg 文件。
如果沒有這個文件,則使用如下命令:
%USERPROFILE%\.idlerc\
該命令會進入一個文件夾,在該文件夾下新建一個文本文件,把名字修改為 config-highlight.cfg,右鍵使用記事本打開。
然后將下面的這段內(nèi)容全部拷貝粘貼進去
[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
如下圖:

拷貝進去后,保存并關(guān)閉。
關(guān)閉 IDLE 重新打開,進入剛才的設(shè)置界面,點擊 Highlights,選擇剛才配置的主題 Obsidian 或 tango。

然后愉快的編碼吧,好看的字體和配色也會讓自己學(xué)習(xí)的興趣增加不少!
其余的編碼工具包括 Sublime text、Eclipse 等,請參考其他網(wǎng)上教程。
