您的位置:首页 > 编程语言 > Python开发

Python专业人士笔记Ch3 缩进,Ch4注释及文档说明

2018-03-31 10:02 531 查看
3.1: Simple example
: are used to declare an indented codeblock冒号声明缩进
3.2: How Indentation is Parsed
3.3: Indentation Errors
4: Comments and Documentation注释及文档说明
4.1: Single line, inline and multilinecomments
Single line comment单行注释
# This is a single line comment in Python
Inline comment行内注释
print("Hello World") # This lineprints "Hello World"
Comments spanning multiple lines have""" or ''' 多行注释用三层双引号或单引号
"""
This type of comment spans multiple lines.
These are mostly used for documentation offunctions, classes and modules.
"""
4.2: Programmatically accessing docstrings编程用文档说明
用help()或func.__doc__访问函数内部说明
4.3: Write documentation using docstrings

def hello(name):
"""Greet someone.
Print a greeting ("Hello") for the person with the given name.
"""
print("Hello "+name)
class Greeter:
"""An object used to greet people.Python® Notes for Professionals 38
It contains multiple greeting functions for several languages
and times of the day.
"""
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: