python人机猜拳代码注释_用英语学Python | Day2 Python 注释

Python注释的作用

Comments can be used to explain Python code. (解释代码)

Comments can be used to make the code more readable. (提高代码的可读性)

Comments can be used to prevent execution when testing code. A comment does not have to be text that explains the code, it can also be used to prevent Python from executing code.(在测试代码时,可以使用注释来阻止执行)

Python 注释的写法

1. 每行以#开头。(Comments starts with a #.)

#This is a comment

print("Hello, World!")

2. 以#开头,放在一行的末尾。(Comments can be placed at the end of a line, and Python will ignore the rest of the line.)

print("Hello, World!") #This is a comment

3. 多行注释,可以每行以#开头。(To add a multiline comment you could insert a # for each line.)

#This is a comment

#written in

#more than just one line

print("Hello, World!")

4. 多行注释,可以使用多行字符串(三引号)。(Use a multiline string. Since Python will ignore string literals that are not assigned to a variable, you can add a multiline string (triple quotes) in your code, and place your comment inside it. 由于 Python 将忽略未分配给变量的字符串文字,因此您可以在代码中添加多行字符串(三引号),并在其中添加注释)

"""

This is a comment

written in

more than just one line

"

""

print("Hello, World!")

注:英文和中文内容来自www.w3cschool.com

如果你有任何建议或想法,欢迎在下面留言告诉我哦!

也欢迎关注我的微信公众号:英语三年之约

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值