首页 技术 正文
技术 2022年11月17日
0 收藏 652 点赞 3,317 浏览 2405 个字

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

  1. 修改字体

    个人比较喜欢 DejaVu Sans Mono 这种字体,自动第一次用 ubuntu 系统就喜欢上了这种类似的字体。可根据喜好选择对应的字体,右边展示的是当前字体各种文字的显示样式。

  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

如下图:

拷贝进去后,保存并关闭。

关闭 IDLE 重新打开,进入刚才的设置界面,点击 Highlights,选择刚才配置的主题 Obsidiantango

然后愉快的编码吧,好看的字体和配色也会让自己学习的兴趣增加不少!

其余的编码工具包括 Sublime text、Eclipse 等,请参考其他网上教程。

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,111
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,584
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,431
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,203
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,838
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,922