python中如何快捷添加注释
本人使用的编辑器是pycharm,有三种注释方式:
1、用 一对""" 括起来要注释的代码块。
2、用一对'''括起来要注释的代码块。
3、选中要注释的代码,按下ctrl+/注释。
实例
#!/usr/bin/python #coding=gbk #Filename:if.py #----->1.用一对"""括起来要注释的代码: """ number=23 guess=int(raw_input('Enteraninteger:')) ifguess==number: print'Congratulations,youguessedit.'#Newblockstartshere print"(butyoudonotwinanyprizes!)"#Newblockendshere elifguess<number: """ #----->2.用一对'''括起来要注释的代码块: ''' print'No,itisalittlehigherthanthat'#Anotherblock #Youcandowhateveryouwantinablock... else: ''' #----->3.选中要注释的代码,按下ctrl+/注释: #print'No,itisalittlelowerthanthat' ##youmusthaveguess>numbertoreachhere #print'Done' ##Thislaststatementisalwaysexecuted,aftertheifstatementisexecuted
推荐学习《python教程》。
本网站文章仅供交流学习 ,不作为商用, 版权归属原作者,部分文章推送时未能及时与原作者取得联系,若来源标注错误或侵犯到您的权益烦请告知,我们将立即删除.