我们要做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. [Leetcode] N-Queens 系列

    N-Queens 系列题解 题目来源: N-Queens N-Queens II N-Queens The n-queens puzzle is the problem of placing n qu ...

  2. [转载]hazard pointer

    hazard pointer 转载自: http://hi.baidu.com/rodimus/item/f6539cc179894f2f47d5c0ef 这是用于解决多线程并发下内存的回收,一块内存 ...

  3. UNDO自我理解总结

    [场景] 当在更新数据的时候,发现更新的值写错了,这时就需要将已经更新的地方恢复到原始数据. [基本概念] 在更新的过程中,Oracle会将原始的数据都放入到UNDO里,这样当以上情况发生后,就可以从 ...

  4. 报错:/application/zabbix/sbin/zabbix_server: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory

    启动zabbix_server时报错: /application/zabbix/sbin/zabbix_server: error while loading shared libraries: li ...

  5. sql函数应用例子

    select p.province, data.existUserCount, data.addUserCount, data.cancelUserCount, data.threedayCancel ...

  6. 秀尔算法:破解RSA加密的“不灭神话” --zz

    http://netsecurity.51cto.com/art/201508/488766.htm RSA加密曾被视为最可靠的加密算法,直到秀尔算法出现,打破了RSA的不灭神话. RSA加密 VS ...

  7. jquery datatable客户端分页保持

    请加入下面注释的参数,并强制刷新浏览器,即可解决,关键配置: "bStateSave":true, $("#tableID").DataTable({ &quo ...

  8. 【严蔚敏】【数据结构题集(C语言版)】1.17 求k阶斐波那契序列的第m项值的函数算法

    已知k阶斐波那契序列的定义为 f(0)=0,f(1)=0,...f(k-2)=0,f(k-1)=1; f(n)=f(n-1)+f(n-2)+...+f(n-k),n=k,k+1,... 试编写求k阶斐 ...

  9. [实战]MVC5+EF6+MySql企业网盘实战(23)——文档列表

    写在前面 上篇文章实现了图片列表,这篇文章实现文档列表将轻车熟路,因为逻辑基本相似,只是查询条件的不同.这里将txt,doc,docx,ppt,pptx,xls,xlsx的文件都归为文档列表中. 系列 ...

  10. [实战]MVC5+EF6+MySql企业网盘实战(20)——Bootstrap Paginator

    写在前面 考虑到数据量的问题,特引入bootstrap的分页插件.插件下载地址:https://github.com/lyonlai/bootstrap-paginator 系列文章 [EF]vs15 ...