当前位置:网站首页> 2. # 代码注释
2. # 代码注释
2022-08-01 02:31:00 【安迪Python】
2. Python # 代码注释
1. 什么是代码注释
代码注释即对代码进行批注说明。
相当于给一个英文单词批注中文释义。
【温馨提示】注释是给程序员自己看的,不会被电脑执行。
【示例】
# 用print函数输出一个整数
print(520)
520
上述代码中的第1行是注释,用来解释第2行代码。
2. 注释语法
一行注释语句通常由4部分组成:
1.#
2.空格
3.注释内容
4.注释位置
【解析】

1.#是注释符号,位于注释行的开头;
2.#后面有一个空格,空格是为了批注看起来更美观;
3.写入注释内容;
4.注释可以在代码的上一行,也可以在代码的末端。

3. 注释位置
1. 注释在代码的上一行
# 用print函数输出一个整数
# 注意括号要使用英文小括号
print(520)
【终端输出】
520
2. 注释在代码的末端
print(520) # 用print函数输出一个整数
【终端输出】
520
4. 课堂练习
自己动手用print( )函数输出今天的日期,并为其写一行批注。
边栏推荐
- Basic implementation of vector
- 七月集训(第31天) —— 状态压缩
- sqlserver cannot connect remotely
- GDB source code analysis series of articles five: dynamic library delay breakpoint implementation mechanism
- [Data analysis] Based on matlab GUI student achievement management system [including Matlab source code 1981]
- Simple vim configuration
- /usr/sbin/vmware-authdlauncher: error while loading shared libraries: libssl.so.1.0.2*Solution
- After specifying set 'execution.savepoint.path', restart flinksql and report this error
- Inheritance Considerations
- 更换树莓派内核
猜你喜欢
![ROS2 series of knowledge (4): understand the concept of [service]](/img/14/8de92a89d9c4b6476ac37408bc7788.png)
ROS2 series of knowledge (4): understand the concept of [service]

Summary of JVM interview questions (continuously updated)

MYSQL logical architecture
![leetcode: 1562. Find latest grouping of size M [simulation + endpoint record + range merge]](/img/72/f52b5d3dcdb271f096c3e5108f0042.png)
leetcode: 1562. Find latest grouping of size M [simulation + endpoint record + range merge]

被 CSDN,伤透了心

HCIP(15)

更换树莓派内核

MYSQL Keyword Explain Analysis

树莓派 的 arm 版的 gcc 安装 和环境变量的配置

Key Points Estimation and Point Instance
随机推荐
What is the meaning of JS timestamp?Know SQL will consider to add a timestamp, JS timestamp for the scene?
七月集训(第31天) —— 状态压缩
C string array reverse
Js replication
IDEA does not recognize the module (there is no blue square in the lower right corner of the module)
Chain programming, packages, access
Inheritance Considerations
MYSQL Keyword Explain Analysis
链式编程、包、访问权限
Nmap manuals - the full version
RTL8762DK PWM (seven)
pdb drug comprehensive database
如何下载Keil包
RTL8762DK WDG (six)
Beijing suddenly announced that yuan universe big news
IDEA无法识别module(module右下角没有蓝色小方块)
500 miles
Parse the bootargs from the device tree (dtb format data)
Summary of MVCC
被 CSDN,伤透了心