zoukankan      html  css  js  c++  java
  • Python 极简教程(二)编码工具

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

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

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

    基本使用

    打开工具,Windows 开始菜单 > 所有程序 > Python 3.6 > IDLE (Python 3.6 32-bit)
    IDLE菜单位置
    打开后,界面如下:
    IDLE界面

    在练习过程中,如果需要创建 Python 文件,也可以通过 IDLE 操作:
    打开File > New File 或者使用快捷键Ctrl + N
    创建 Python 文件
    在新建的窗口中输入 Python 代码
    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
    

    如下图:
    config-highlight.cfg
    拷贝进去后,保存并关闭。

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

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

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

    人生苦短,我用 Python 做测试!
  • 相关阅读:
    496 服务器渲染 VS 客户端渲染
    495 队列,优先级队列
    493 JS中数据类型检测的四种方案
    492 js的继承:原型继承,CALL继承,寄生组合式继承,ES6中的类和继承
    491 CALL和APPLY以及BIND语法(含BIND的核心原理),CALL和APPLY的应用(类数组借用数组原型方法),CALL源码解析及阿里面试题
    490 JavaScript的this的五种指向
    488 DOM0和DOM2事件绑定的原理、使用、区别
    487 函数的三种角色:普通函数,构造函数(类),普通对象,原型链清明上河图
    486 原型及原型链模式:3个重要知识点,从面向对象角度来讲解内置类,hasOwnProperty,原型链方法中的THIS问题,基于内置类的原型扩展方法
    485 面向对象:单例设计模式,工厂模式,什么是面向对象,构造函数,instanceof,构造函数中的局部变量以及new构造函数时不加括号
  • 原文地址:https://www.cnblogs.com/zmll/p/10611004.html
Copyright © 2011-2022 走看看