1 个回答|306 次阅读
1、注释以#开头,Python 将忽略#后面的同一行的内容
例:
#This is a comment
print("Hello, World!")
2、注释可以放在一行的末尾,Python将忽略该行的其余部分:
例:
print("Hello, World!") #This is a comment
3、注释不一定是解释代码的文本,也可以用来防止Python执行某些代码:
例:
#print("Hello, World!")
print("Cheers, Python!")
请先 登录 后评论