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 #使用 ...
随机推荐
- three.js_ "Failed to execute 'texImage2D' on 'WebGLRenderingContext': tainted canvases may not be loded."
这个报错是请求图片跨域了. 1.当我们使用thee.js的时候肯定会碰到利用各种请求去向服务器请求贴图. 2.假设我们获取的是图片在服务器上的路径然后我们用 加载贴图到这里都是没有问题当我们在贴图加载 ...
- 删除none的images
脚本 #!/bin/bash docker ps -a | grep "Exited" | awk '{print $1 }'|xargs docker stop docker p ...
- ORACLE数据库导出导入数据
准备工作: 1.登录管理员system 2.create directory dbdata as 'C:\oracle\tempData';--创建备份文件夹 3.grant read,write o ...
- samba中的pdbedit用法
pdbedit用于在samba服务器中创建用户: 它的用法包括 pdbedit -a username:新建Samba账户. pdbedit -x username:删除Samba账户. pdbedi ...
- PHP利用rand(1,100)函数产生10个1~100之间的随机数
//echo rand(1,100); $max=0; $min=100; for($i=0;$i<=9;$i++){ $rand[$i]=rand(1,100); if($rand[$i]&g ...
- Git提交记住用户名和密码
https://www.baidu.com/link?url=R14MHMloypfAfIeiQwCINfY1AZlcoSU7-tYdnqC1PxfmFKs4TWzLOPdtyJbWVfqMqOkRx ...
- acm专题---动态规划
题目来源:http://hihocoder.com/problemset/problem/1400?sid=983096 #1400 : Composition 时间限制:10000ms 单点时限:1 ...
- CSU 1425 Prime Summation
原题链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1425 DP题. f[i][j]表示当前数字为i,分解式中最大质数为j的方案数,那么,状态 ...
- jmeter------线程组(默认)
Jmeter中的采样器必须要基于线程组. 一.添加线程组 在测试计划上右键,然后选择,如下图: 二.线程组界面 三.线程组界面配置说明 1.名称:线程组自定义名称: 2.注释:添加的一些备注说明信息, ...
- spring-cloud-sleuth+zipkin追踪服务实现(二)
1. 简述 在上一节<spring-cloud-sleuth+zipkin追踪服务实现(一)>中,我们使用microservice-zipkin-server.microservice-z ...