云学编程的第3天—【微软官方python入门教程 P7-P8笔记】2021-11-03 注释

本文介绍了如何使用代码注释来提高代码的可读性和维护性。通过示例展示了何时及如何添加注释,包括实验性代码的注释处理、调试过程中的注释应用等。此外还提到了一些常用的键盘快捷键。

 

Comments are a way of documenting your code.

you can put comments in front of code that you're experimenting with, Maybe you try a line of code and it isn't working or it is working you want to try changing someting. Rather than deleting the line of code, sometimes i'll comment out that line of code.

#This is a comment in my code it does nothing
#No output will be displayed!

Comment calls to other programs to explain their purpose.

#Enable PIN check as listed in
#security requirements
enable_pin(current_user,pin)

Comments document your code so you and other programmers can understand the code.

#Using double quotes for this string because
#the string itself contains a single quote
print("It's a small world after all")

Commenting lines of code can help you debug and figure out which line of code is causing an error

I basically commented out all code, turned a whole bunch of lines of code into comments, and then see if the first five lines of code in my program worked. The first five line worked, then uncomment the next five lines, still no error message. Uncomment the next five lines, and so on until I see the error message.

print('hello world')
#print('It's a small world after all')

ps:keyboard shortcut for # is C+/

P8实操:

·可以用\转换单引号意义

 

 快捷键也可以是C+K+C(comment)C+K+U(uncomment)

 

 

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值