1.单行注释
python中单行注释采用 #开头
2.多行注释
3.代码间注释
4.特殊注释
"""三个引号是注释号格式
,
这些注释保存在方法的__doc__属性中,可以打印显示。
python中单行注释采用 #开头
点击(此处)折叠或打开
- #!/usr/bin/python
- #filename: searchengine.py
- #input: onne
- #output: none
- #writer: mail:15933533880@163.com
- class crawler:
- """
- This is a crawler class.
- It contains the statement of some function
- """
- #initial crawler class
- def __init__(self, dbname):
- pass
-
- def __del__(self):
- pass
- def dbcommit(self):
- pass
然后python蛋疼的没有块注释,所以现在推荐的多行注释也是采用的 #
点击(此处)折叠或打开
- #!/usr/bin/python
- #filename: searchengine.py
- #input: onne
- #output: none
- #writer: mail:15933533880@163.com
点击(此处)折叠或打开
- class crawler:
- #initial crawler class
- def __init__(self, dbname):
- pass
比如#! /usr/bin/python 这句注释的意思就是告诉LINUX/UNIX去找到python的翻译器,大部分文件都不需要这个,只在要求也执行的文件中添加。
关于蛋疼的中文编码: # coding = utf-8 【注:这句代码蛋疼的必须放在第二行啊,而且多个空格都不行啊!】
5.python的福利!!
python在注释中有一个非常有用的东西是 doc String ,它可以用于模块、函数和类的描述:(其实总结起来都是类)下面是一个标准的方法注释
点击(此处)折叠或打开
- class crawler:
- """
- This is a crawler class.
- It contains the statement of some function
- """
- #initial crawler class
- def __init__(self, dbname):
- pass
-
- def __del__(self):
- pass
- def dbcommit(self):
- pass