Python 极简教程(二)编码工具

发布时间:2020-08-11 15:08:18 作者:minzhung
来源:网络 阅读:194

Python 的编码工具很多。目前最流行的是 pycharm,关于 pycharm 的安装使用请参考 PyCharm安装使用教程。

而学习过程中,我觉得最好用的,还是 Python 自带的练习工具 IDLE。这款工具不用安装,装好 Python 后就有了。

这款工具最大的好处,就是变量的值、函数返回值都可以直接展示,不用打印即可查看。这极大了方便学习过程中,需要不断的查看各种语句的执行结果。

基本使用

打开工具,Windows 开始菜单 > 所有程序 > Python 3.6 > IDLE (Python 3.6 32-bit)
Python 极简教程(二)编码工具
打开后,界面如下:
Python 极简教程(二)编码工具

在练习过程中,如果需要创建 Python 文件,也可以通过 IDLE 操作:
打开File > New File 或者使用快捷键Ctrl + N
Python 极简教程(二)编码工具
在新建的窗口中输入 Python 代码
Python 极简教程(二)编码工具
然后可以运行,运行方式可以直接按 F5或者点击菜单栏中的Run > Run Module
Python 极简教程(二)编码工具
运行后会弹出要求保存的提示
Python 极简教程(二)编码工具
点击确定后,保存到你存放练习笔记的目录即可。
Python 极简教程(二)编码工具
运行后,会回到 Python IDLE 的 shell 界面,上面显示了你当前运行的文件名称。你可以接下来在光标位置继续操作。
Python 极简教程(二)编码工具

修改 IDLE 主题

当然我现在用的主题修改过,修改主题的方法如下:
打开菜单 Options > Config IDLE
Python 极简教程(二)编码工具

  1. 修改字体
    个人比较喜欢 DejaVu Sans Mono 这种字体,自动第一次用 ubuntu 系统就喜欢上了这种类似的字体。可根据喜好选择对应的字体,右边展示的是当前字体各种文字的显示样式。
    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 等,请参考其他网上教程。

下一篇 数据类型

推荐阅读:
  1. Python 极简教程(六)运算符
  2. Python 极简教程(五)输入输出

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

python

上一篇:iptables的学习

下一篇:【Redis】Sentinel 高可用架构

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》