美文网首页
Python中备注的使用

Python中备注的使用

作者: DingDingYuan | 来源:发表于2019-06-01 15:20 被阅读0次

单行备注:

# 井号之后的代码都不会被执行
a=1 # 这里是单行备注,不会被执行

多行备注

"""
这里面无论加什么都不会执行
随便加
rm -fr /*
I love you all!
I hate you all!
"""
# 
a= 1

同时备注多行:
选择多行然后,普通键盘:control+/;Mac键盘: Command+/


gif_toggle.6424d45ed925.gif

函数与函数包的Doc文件

def sparsity_ratio(x: np.array) -> float:
    """Return a float

    Percentage of values in array that are zero or NaN
    """

以上文字将成为.doc的一部分

# -*- coding: utf-8 -*-
"""A module-level docstring

Notice the comment above the docstring specifying the encoding.
Docstrings do appear in the bytecode, so you can access this through
the ``__doc__`` attribute. This is also what you'll see if you call
help() on a module or any other Python object.
"""

参考
https://realpython.com/python-comments-guide/
https://www.python.org/dev/peps/pep-0257/#one-line-docstrings

相关文章

  • Python中备注的使用

    单行备注: 多行备注 同时备注多行:选择多行然后,普通键盘:control+/;Mac键盘: Command+/ ...

  • pyenv

    备注:使用 pyenv 安装 python 时,默认从 python.org 下载指定版本,往往特别慢,经常下载失...

  • SQL语句提示利器--mycli

    使SQL语句具有提示功能 使用pip下载mycli 备注:pip是Python的包管理工具,没有Python环境的...

  • Ubuntu下Python虚拟环境的安装

    备注:当前Ubuntu版本是16.04.3版本,默认使用的Python版本是Python2的版本。1.安装Pyth...

  • python操作数据库之Mysql

    集群环境:CDH5.8python3版本:3.6.8pip3版本:18.1 备注: 参数设置sql中的参数使用%s...

  • Python-时间日历

    备注:本文学习整理自菜鸟教程 一、简介 Python中使用time和calendar模块格式化日期和时间 使用时需...

  • nsq01介绍

    初始 备注: 我的环境是CentOS 7, Python 2.7.13 术语 主题(topic) 在NSQ中,消息...

  • CenOS6.9 从零开始构建python开发环境

    安装python 备注:执行 ./configure --prefix=/usr/local/python/pyt...

  • Python-分支、循环、条件与枚举

    一、条件 1、if、else 2、if、elif 备注: python中无switch语法 二、循环 1、whil...

  • 使用Python重命名多个文件

    使用Python重命名多个文件 今天,我们使用的是python中的OS模块。 在python3中,rename()...

网友评论

      本文标题:Python中备注的使用

      本文链接:https://www.haomeiwen.com/subject/lyhatctx.html