当前位置:首页 > 云计算 > 正文内容

python中如何快捷添加注释

2022-05-04 03:11:32云计算2

本人使用的编辑器是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教程》。

本网站文章仅供交流学习 ,不作为商用, 版权归属原作者,部分文章推送时未能及时与原作者取得联系,若来源标注错误或侵犯到您的权益烦请告知,我们将立即删除.

本文链接:https://www.xibujisuan.cn/8759.html

标签: Python