python申明文件编码_python编码规范(四)--注释,文档

1.注释块注释

块注释内部的段落通常只用一个#作为空行的分隔#!/usr/bin/env python# -*- coding:utf-8 -*-# title           :backup_full.py# description     :MySQL全量备份# author          :w.s.w# date            :20180601# version         :1.0# notes           :# python_version  :2.7#==============================================================================行内注释

井前至少使用两个空格和代码语句分开,#后面有单个空格,注意避免使用无意义的注释x = x + 1                 # 行内注释非公共方法注释

非公共的方法没有必要写文档说明,但是应该有一个描述方法具体作用的注释,这个注释应该在def那一行之后def backup_synth(args):

# 增量备份

logger.info('backup_synth')

2.文档说明公共模块

写在块注释后,import前#!/usr/bin/env python# png.py - PNG encoder/decoder in pure Python## Copyright (C) 2006 Johann C. Rocholl # Portions Copyright (C) 2009 David Jones # And probably portions Copyright (C) 2006 Nicko van Someren ## Original concept by Johann C. Rocholl.## LICENCE (MIT)"""

Pure Python PNG Reader/Writer

And now, my famous members

--------------------------

"""# http://www.python.org/doc/2.2.3/whatsnew/node5.htmlfrom __future__ import generators

__version__ = "0.0.18"from array import array公共类,公共方法

写在def, class后,取一层缩进def backup_alone(self, args):

"""单通道备份函数

Parameters:

filesystem(str): 文件系统

mountpoint(str): 挂载点

include(str): 包含文件

exclude(str): 排除文件

Returns:

pid(str): 进程号

"""

作者:Godric_wsw

链接:https://www.jianshu.com/p/f5e5eebdd430

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值