Python 极简教程(二)编码工具
Python 的编码工具很多。目前最流行的是 pycharm,关于 pycharm 的安装使用请参考 PyCharm安装使用教程。
而学习过程中,我觉得最好用的,还是 Python 自带的练习工具 IDLE
。这款工具不用安装,装好 Python 后就有了。
这款工具最大的好处,就是变量的值、函数返回值都可以直接展示,不用打印即可查看。这极大了方便学习过程中,需要不断的查看各种语句的执行结果。
基本使用
打开工具,Windows 开始菜单 > 所有程序 > Python 3.6 > IDLE (Python 3.6 32-bit)
打开后,界面如下:
在练习过程中,如果需要创建 Python 文件,也可以通过 IDLE 操作:
打开File > New File
或者使用快捷键Ctrl + N
在新建的窗口中输入 Python 代码
然后可以运行,运行方式可以直接按 F5
或者点击菜单栏中的Run > Run Module
运行后会弹出要求保存的提示
点击确定后,保存到你存放练习笔记的目录即可。
运行后,会回到 Python IDLE 的 shell 界面,上面显示了你当前运行的文件名称。你可以接下来在光标位置继续操作。
修改 IDLE 主题
当然我现在用的主题修改过,修改主题的方法如下:
打开菜单 Options > Config IDLE
- 修改字体
个人比较喜欢 DejaVu Sans Mono 这种字体,自动第一次用 ubuntu 系统就喜欢上了这种类似的字体。可根据喜好选择对应的字体,右边展示的是当前字体各种文字的显示样式。 - 修改主题样式
需要找到config-highlight.cfg
文件,直接使用windows键 + R
打开"运行",在运行窗口输入(拷贝粘贴进去即可):notepad %USERPROFILE%\.idlerc\config-highlight.cfg
这句命令会用记事本打开
config-highlight.cfg
文件。
如果没有这个文件,则使用如下命令:%USERPROFILE%\.idlerc\
该命令会进入一个文件夹,在该文件夹下新建一个文本文件,把名字修改为
config-highlight.cfg
,右键使用记事本打开。
然后将下面的这段内容全部拷贝粘贴进去
[Obsidian]definition-foreground = #678CB1error-foreground = #FF0000string-background = #293134keyword-foreground = #93C763normal-foreground = #E0E2E4comment-background = #293134hit-foreground = #E0E2E4builtin-background = #293134stdout-foreground = #678CB1cursor-foreground = #E0E2E4break-background = #293134comment-foreground = #66747Bhilite-background = #2F393Chilite-foreground = #E0E2E4definition-background = #293134stderr-background = #293134hit-background = #000000console-foreground = #E0E2E4normal-background = #293134builtin-foreground = #dd17e8stdout-background = #293134console-background = #293134stderr-foreground = #FB0000keyword-background = #293134string-foreground = #EC7600break-foreground = #E0E2E4error-background = #293134[tango]definition-foreground = #fce94ferror-foreground = #fa8072string-background = #2e3436keyword-foreground = #8cc4ffnormal-foreground = #ffffffcomment-background = #2e3436hit-foreground = #ffffffbreak-foreground = #000000builtin-background = #2e3436stdout-foreground = #eeeeeccursor-foreground = #fce94fhit-background = #2e3436comment-foreground = #73d216hilite-background = #edd400definition-background = #2e3436stderr-background = #2e3436break-background = #2e3436console-foreground = #87ceebnormal-background = #2e3436builtin-foreground = #ad7fa8stdout-background = #2e3436console-background = #2e3436stderr-foreground = #ff3e40keyword-background = #2e3436string-foreground = #e9b96ehilite-foreground = #2e3436error-background = #2e3436
如下图:
拷贝进去后,保存并关闭。
关闭 IDLE 重新打开,进入刚才的设置界面,点击 Highlights
,选择刚才配置的主题 Obsidian
或 tango
。
然后愉快的编码吧,好看的字体和配色也会让自己学习的兴趣增加不少!
其余的编码工具包括 Sublime text、Eclipse 等,请参考其他网上教程。
下一篇 数据类型