python中注释的方法

python中单行注释,和java或shell语言无什么区别,在行首加上“#”进行标识:

#print("这是一行被注释的代码")

python中多行注释使用三个单引号作为开头即“'''”与三个单引号作为结束对一段代码进行注释,例如:

#以下是一段被注释的代码

'''
name = input("tell me your name :")
sex = input(" you are a man or woman :")
if sex == "man" :
    print("you are a Handsome boys :" + name)
elif sex == "woman":
    print("you are a beautiful girl :" + name)
else:
    print(" sorry, I can't see your gender")
'''

注释后可在代码块中发现明显的颜色区分。

猜你喜欢

转载自blog.csdn.net/zcb_data/article/details/107371100