Python中的注释以 # 号开头,直至物理行的行尾结束。可是出现在字符串中则失去注释效果,仅被当作普通的#号。
Some examples:
# this is the first comment
spam = 1 # and this is the second comment
# ... and now a third!
text = "# This is not a comment because it's inside quotes."
Comments in Python start with the hash character,
#
, and extend to the end of the physical line. A comment may appear at the start of a line or following whitespace or code, but not within a string literal. A hash character within a string literal is just a hash character. Since comments are to clarify code and are not interpreted by Python, they may be omitted when typing in examples.