知行编程网知行编程网  2022-09-14 20:30 知行编程网 隐藏边栏  1 
文章评分 0 次,平均分 0.0
导语: 本文主要介绍了关于如何给python代码快速添加注释的相关知识,包括python代码的单行注释,以及python单行注释开头这些编程知识,希望对大家有参考作用。

如何快速为python代码添加注释

python代码快速添加注释的方法

选中要注释的代码,按下ctrl+/注释。

实例

#----->1.用一对"""括起来要注释的代码:
"""
  number = 23
  guess = int(raw_input('Enter an integer : '))
  if guess == number:
  print 'Congratulations, you guessed it.' # New blockstarts here
  print "(but you do not win any prizes!)" # New blockends here
  elif guess < number:
"""
#----->2.用一对'''括起来要注释的代码块:
'''
  print 'No, it is a little higher than that' #Another block
# You can do whatever you want in a block ...
else:
'''
#----->3.选中要注释的代码,按下ctrl+/注释:
#   print 'No, it is a little lower than that'
# # you must have guess > number to reach here
# print 'Done'
# # This last statement is always executed, after the ifstatement is executed

本文为原创文章,版权归所有,欢迎分享本文,转载请保留出处!

知行编程网
知行编程网 关注:1    粉丝:1
这个人很懒,什么都没写
扫一扫二维码分享