python开发_python代码风格(coding style)
我们要做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)的更多相关文章
- python开发_python关键字
python3.3.2中的关键字如下: The following identifiers are used as reserved words, or keywords of the languag ...
- python的PEP8 代码风格指南
PEP8 代码风格指南 这篇文章原文实际上来自于这里:https://www.python.org/dev/peps/pep-0008/ 知识点 代码排版 字符串引号 表达式和语句中的空格 注释 版本 ...
- python开发_python操作mysql数据库
如果你还没有准备好开发环境,你不妨花上一小点时间去看看:python开发_mysqldb安装 本篇blog是有关python操作mysql数据的相关内容. 我做了一个demo: 先看运行效果: mys ...
- python开发_python概述
Python(KK 英语发音:/ˈpaɪθən/,是一种面向对象.直译式计算机程序设计语言, 由Guido van Rossum于1989年底发明,第一个公开发行版发行于1991年. Python语法 ...
- python开发_python中的module
在python中,我们可以把一些功能模块化,就有一点类似于java中,把一些功能相关或者相同的代码放到一起,这样我们需要用的时候,就可以直接调用了 这样做的好处: 1,只要写好了一个功能模块,就可以在 ...
- python开发_python中的变量:全局变量和局部变量
如果你在为python中的变量:全局变量和局部变量头疼,我想这篇blog会给你帮助 运行效果: 代码部分: #Python中的变量:全局变量和局部变量 #在很多语言中,在声明全局变量的时候,都喜欢把全 ...
- python开发_python中字符串string操作
在python中,对于字符串string的操作,我们有必要了解一下,这样在我们的以后的开发中会给我们带来很多方便 下面是我学习的笔记: #python-string #python中的字符串用单引号' ...
- jquery开发之代码风格
1,链式操作风格. (1) 对于同一个对象不超过三个操作的.可直接写成一行.代码例如以下: $("li").show().unbind("click"); (2 ...
- python开发_python中str.format()
格式化一个字符串的输出结果,我们在很多地方都可以看到,如:c/c++中都有见过 下面看看python中的字符串格式函数str.format(): 1 #使用str.format()函数 2 3 #使用 ...
随机推荐
- stanfordCorenlp在python3中的安装使用+词性学习
1 安装 前言 Stanford CoreNLP的源代码是使用Java写的,提供了Server方式进行交互.stanfordcorenlp是一个对Stanford CoreNLP进行了封装的Pytho ...
- layui的模块化和非模块化使用
非模块化和模块化的区别是 非模块化不用每次都调用layui.use([],fun...)引入对应模块,引入的JS是/layui/layui.all.js 模块化必须每次都调用layui.use([], ...
- oracle链接指定实例
sqlplus /@ORACLE_SID as sysdba; 其中ORACLE_SID为具体的实例名称, 比如连接到orcl实例就执行命令: sqlplus /@orcl as sysdba; se ...
- PHP对象1: 创建对象与 $this
<?php class perl{ public $name; function __construct($name){ echo '一个对象造好了<br/>'; $this-> ...
- ISG2018 web题Writeup
0x01.命令注入 这题可以使用burpsuite扫出来,但是可能需要测一下. 得知payload为:i%7cecho%20gzavvlsv9c%20q9szmriaiy%7c%7ca%20%23'% ...
- 解读Linux命令格式(转)
解读Linux命令格式 环境 Linux HA5-139JK 2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:48 EDT 2009 x86_64 x86_64 x8 ...
- GUC-3 模拟CAS算法
/* * 模拟 CAS 算法 */ public class TestCompareAndSwap { public static void main(String[] args) { final C ...
- Loadrunner脚本开发规范
Loadrunner脚本开发规范 目录 1.一般约定... 3 2.代码注释约定... 4 3.格式化代码... 5 1.一般约定 1.1具体脚本规则,必须在具体代码中加注释,以便脚本开发人员阅读和理 ...
- Mysql 主键约束PrimaryKey
Mysql 主键约束Primary Key 今天来简单的讲一下主键约束. 假如有一张学生信息表,里面记录了学生的学号 ,姓名,成绩等,那么,会不会有两个学号相同的学生,答案肯定是否定的,如果有的话也只 ...
- (14) go 结构体
1. 声明一个结构体 2.属性 如果是 指针 切片 map 需要用make 3.赋值 (2) (3) (4) 4. 正确,字段相同,数据类型相同,名字相同 5.