当前位置:网站首页>2. # code comments
2. # code comments
2022-08-01 03:07:00 【Andy Python】
2. Python # 代码注释
1. 什么是代码注释
Code comments are comments on the code.
It is equivalent to annotating a Chinese definition for an English word.
【温馨提示】注释是给程序员自己看的,will not be executed by the computer.
【示例】
# 用printThe function outputs an integer
print(520)
520
上述代码中的第1行是注释,to explain the2行代码.
2. 注释语法
A one-line comment statement usually consists of 4部分组成:
1.#
2.空格
3.注释内容
4.注释位置
【解析】

1.#
是注释符号,at the beginning of a comment line;
2.#后面有一个空格,The spaces are there to make the comments look nicer;
3.Write comments;
4.Comments can be on the previous line of code,Also at the end of the code.

3. 注释位置
1. The comment is on the previous line of the code
# 用printThe function outputs an integer
# Note that parentheses should be used in English parentheses
print(520)
【终端输出】
520
2. Comments are at the end of the code
print(520) # 用printThe function outputs an integer
【终端输出】
520
4. 课堂练习
自己动手用print( )The function outputs today's date,and write a line comment for it.
边栏推荐
- 北京突然宣布,元宇宙重大消息
- 《少年派2》:新男友竟脚踩两只船,林妙妙与钱三一感情回温
- Chain programming, packages, access
- Basic usage concepts of vim
- [SemiDrive source code analysis] series article link summary (full)
- test
- Compiled on unbutu with wiringPi library and run on Raspberry Pi
- By Value or By Reference
- 2022 CSP-J1 CSP-S1 Round 1 Preliminary Competition Registration Guide
- Solve the problem that when IDEA creates a new file by default, right-click, new, there is no XML file
猜你喜欢
ARM cross compilation
二舅
New York University et al | TM-Vec: Template Modeling Vectors for Rapid Homology Detection and Alignment
The fledgling Xiao Li's 114th blog project notes: Wisdom cloud intelligent flower watering device combat (3) - basic Demo implementation
IDEA modifies the annotation font
Four ways the Metaverse is changing the way humans work
Solve the problem that Excel opens very slowly after installing MySQL
[Data analysis] Based on matlab GUI student achievement management system [including Matlab source code 1981]
win10 fixed local IP
JS new fun(); 类与实例 JS基于对象语言 只能通过书写构造函数充当类
随机推荐
[Search topic] After reading the inevitable BFS solution to the shortest path problem
You need to know the TCP wave four times
北京突然宣布,元宇宙重大消息
设备树——dtb格式到struct device node结构体的转换
内核的解压缩过程详解
普通用户无法访问hgfs目录
How to download the Keil package
The fledgling Xiao Li's 113th blog project notes: Wisdom cloud smart flower watering device combat (2) - basic Demo implementation
设备树的树形结构到底是怎样体现的?
Chain programming, packages, access
Talking about hardware device computing storage and data interaction
second uncle
Summary of JVM interview questions (continuously updated)
The fledgling Xiao Li's 114th blog project notes: Wisdom cloud intelligent flower watering device combat (3) - basic Demo implementation
HCIP(14)
The bigger and bigger the project is, I split it like this
如何下载Keil包
Modify Postman installation path
C string array reverse
黑客到底可以厉害到什么程度?