当前位置:网站首页>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.
边栏推荐
- Google Earth Engine - Error resolution of Error: Image.clipToBoundsAndScale, argument 'input': Invalid type
- [cellular automata] based on matlab interface aggregation cellular automata simulation [including Matlab source code 2004]
- Dart 命名参数语法
- Handwritten binary search tree and test
- Modify Postman installation path
- 【Make YOLO Great Again】YOLOv1-v7全系列大解析(Neck篇)
- Elastic Stack的介绍
- Solve the problem that when IDEA creates a new file by default, right-click, new, there is no XML file
- <JDBC> 批量插入 的四种实现方式:你真的get到了吗?
- button去除黑框
猜你喜欢
随机推荐
By CSDN, torn
Soft Exam Senior System Architect Series: Basic Knowledge of System Development
Elastic Stack的介绍
The bigger and bigger the project is, I split it like this
《少年派2》:新男友竟脚踩两只船,林妙妙与钱三一感情回温
pdb drug comprehensive database
情人节浪漫3D照片墙【附源码】
移动端页面秒开优化总结
【元胞自动机】基于matlab界面聚合元胞自动机模拟【含Matlab源码 2004期】
Guys, MySQL cdc source recycles replication slave and r in incremental process
解决安装MySQL后,Excel打开很慢的问题
修改Postman安装路径
设备树——dtb格式到struct device node结构体的转换
Solve the problem that when IDEA creates a new file by default, right-click, new, there is no XML file
Unity3D study notes 10 - texture array
How to download the Keil package
785. Quick Sort
Dart 命名参数语法
You need to know the TCP wave four times
IDEA modifies the annotation font









