Python多行注释技巧

Python语言本身是没有注释多行的支持的,如果需要注册多行,可以用一个取巧的方法,就是把需要注释的代码块用三个引号括起来,赋值为一个永远都不会使用的字符串变量,例如:

__devilcomment = '''
if bCmpLog == "True":
        self.appendAdsLogToCmpLog("")

if bCmpBinaryLog == "True":
        self.appendBinaryAdsLogToCmpLog(res)

if bCompareResp == "True":
    self.appendResponseToCmpLog(response_strs)

print "move new and debug logs"
self.tools.move (src_db,dst_db)
'''

5 thoughts on “Python多行注释技巧”

Leave a Reply

Your email address will not be published. Required fields are marked *