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

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s