我们要做python开发,我想python中的代码风格我们有必要了解一下

这样对我们自己和他们所编写的代码都有好处的。

下面是8点重要代码风格注意事项:

ONE :  Use 4-space indentation, and no tabs.--用4个空格键进行代码缩进,不要使用tab键.

    4 spaces are a good compromise between small indentation (allows greater nesting depth) and large indentation (easier to read). Tabs introduce confusion, and are best left out.
TWO :  Wrap lines so that they don’t exceed 79 characters.-- 每一行代码不要超过79字符.

    This helps users with small displays and makes it possible to have several code files side-by-side on larger displays.
THREE :  Use blank lines to separate functions and classes, and larger blocks of code inside functions. -- 在函数或者类中使用空白行
FOUR :  When possible, put comments on a line of their own.--添加注释,这个可以帮助你自己和他人阅读代码
FIVE :  Use spaces around operators and after commas, but not directly inside bracketing constructs: a = f(1, 2) + g(3, 4).--在编写代码的过程中,注意使用空格,这样使得你的代码看上去清晰,美观
SIX :  Name your classes and functions consistently; the convention is to use CamelCase for classes and lower_case_with_underscores for functions and methods. Always use self as the name for the first method argument --使用驼峰命名法命名类名;使用'lower_case_with_underscores '这样的方式命名方法或者函数
SEVEN :  Don’t use fancy encodings if your code is meant to be used in international environments. Python’s default, UTF-8, or even plain ASCII work best in any case. -- 统一使用UTF-8的编码方式进行编码
EIGHT :  Likewise, don’t use non-ASCII characters in identifiers if there is only the slightest chance people speaking a different language will read or maintain the code.--不要使用非ascii字符标识符

python开发_python代码风格(coding style)的更多相关文章

  1. python开发_python关键字

    python3.3.2中的关键字如下: The following identifiers are used as reserved words, or keywords of the languag ...

  2. python的PEP8 代码风格指南

    PEP8 代码风格指南 这篇文章原文实际上来自于这里:https://www.python.org/dev/peps/pep-0008/ 知识点 代码排版 字符串引号 表达式和语句中的空格 注释 版本 ...

  3. python开发_python操作mysql数据库

    如果你还没有准备好开发环境,你不妨花上一小点时间去看看:python开发_mysqldb安装 本篇blog是有关python操作mysql数据的相关内容. 我做了一个demo: 先看运行效果: mys ...

  4. python开发_python概述

    Python(KK 英语发音:/ˈpaɪθən/,是一种面向对象.直译式计算机程序设计语言, 由Guido van Rossum于1989年底发明,第一个公开发行版发行于1991年. Python语法 ...

  5. python开发_python中的module

    在python中,我们可以把一些功能模块化,就有一点类似于java中,把一些功能相关或者相同的代码放到一起,这样我们需要用的时候,就可以直接调用了 这样做的好处: 1,只要写好了一个功能模块,就可以在 ...

  6. python开发_python中的变量:全局变量和局部变量

    如果你在为python中的变量:全局变量和局部变量头疼,我想这篇blog会给你帮助 运行效果: 代码部分: #Python中的变量:全局变量和局部变量 #在很多语言中,在声明全局变量的时候,都喜欢把全 ...

  7. python开发_python中字符串string操作

    在python中,对于字符串string的操作,我们有必要了解一下,这样在我们的以后的开发中会给我们带来很多方便 下面是我学习的笔记: #python-string #python中的字符串用单引号' ...

  8. jquery开发之代码风格

    1,链式操作风格. (1) 对于同一个对象不超过三个操作的.可直接写成一行.代码例如以下: $("li").show().unbind("click"); (2 ...

  9. python开发_python中str.format()

    格式化一个字符串的输出结果,我们在很多地方都可以看到,如:c/c++中都有见过 下面看看python中的字符串格式函数str.format(): 1 #使用str.format()函数 2 3 #使用 ...

随机推荐

  1. React 16 源码瞎几把解读 【三 点 一】 把react组件对象弄到dom中去(矛头指向fiber,fiber不解读这个过程也不知道)

    一.ReactDOM.render 都干啥了 我们在写react的时候,最后一步肯定是 ReactDOM.render( <div> <Home name="home&qu ...

  2. /proc/cpuinfo 文件分析(查看CPU信息)

    /proc/cpuinfo文件分析 根据以下内容,我们则可以很方便的知道当前系统关于CPU.CPU的核数.CPU是否启用超线程等信息. <1>查询系统具有多少个逻辑核:cat /proc/ ...

  3. [转载]锁无关的(Lock-Free)数据结构

    锁无关的(Lock-Free)数据结构 在避免死锁的同时确保线程继续 Andrei Alexandrescu 刘未鹏 译 Andrei Alexandrescu是华盛顿大学计算机科学系的在读研究生,也 ...

  4. fedroa20 没法开启ntpd服务器

    1现象:ntpd老是没法开启,ntpd -d显示有个进程占用123端口. [root@vd13crmtb01 ~]# systemctl enable ntpd.service         //开 ...

  5. 不需要打密码的sudo方法

    Linux下频繁输入sudo很麻烦.如果你的账户已经是sudoer了,那么编辑/etc/sudoers,将 %sudo ALL=(ALL:ALL) ALL 修改为: %sudo ALL=(ALL) N ...

  6. 禁用Flash P2P上传

    Mac OS: sudo bash -c 'echo RTMFPP2PDisable=1 >> /Library/Application\ Support/Macromedia/mms.c ...

  7. Weblogic常用监控指标以及监控工具小结

    https://blog.csdn.net/hualusiyu/article/details/39583549

  8. fastdfs5.11+centos7.2 按照部署(二)【转载】

    https://files.cnblogs.com/files/xiaojf/nginx-1.12.0.tar.gz https://files.cnblogs.com/files/xiaojf/li ...

  9. 字符串处理strcpy strcat函数的用法

    C语言函数字符串处理strcpy strcat函数的用法: 1)strcat是用来连接两个字符串的,原型是char *strcat(char *dest,char *src),作用是把src所指字符串 ...

  10. bzoj 1106

    思路:很容易就能想到统计没两对点之间的未匹配点的个数. 在想怎么用数据结构维护这个东西, 没有想到用树状数组能很巧妙地维护出来, 就写了个莫队... 莫队:暴力维护就好了. #include<b ...