Operation check
CentOS 6.5
Python 2.6.6
In Python, it seems that you can use " ""
or'''
for multi-line comments.
Reference
def main():
print "test start"
"""
test1
"""
"""
test2
"""
print "test end"
The first thing I didn't understand was that the comment part of test2 gave me the error ʻIndentation Error: unexpected indent`.
Since python interprets the structure by indent, the comment of test2 was interpreted as "not the definition in main ()" because there is no indent, and an error occurred.
If you do the following, the error will disappear.
def main():
print "test start"
"""
test1
"""
"""
test2
"""
print "test end"
In other words, when writing a multi-line comment, it seems that you need to write it with the same indent as the previous line. This happens for multi-line comments, and single-line comments starting with # can be written from the first digit without worrying about indents.
def main():
print "test start"
"""
test1
"""
#This comment is O.K.
"""
test2
"""
print "test end"
Recommended Posts