python3基礎教程廖雪峰云,python基本代碼教程-(Python基礎教程之三)Python代碼中添加注釋

 2023-11-18 阅读 38 评论 0

摘要:在Python(或任何其他編程語言)中,注釋用于解釋源代碼。注釋描述了代碼,這有助于將來維護應用程序。 python中的注釋 # prints 4 print(2 + 2) print(2 + 3) # prints 5 python3基礎教程廖雪峰云?""" prints the sum of two

在Python(或任何其他編程語言)中,注釋用于解釋源代碼。注釋描述了代碼,這有助于將來維護應用程序。

python中的注釋

# prints 4

print(2 + 2)

print(2 + 3) # prints 5

python3基礎教程廖雪峰云?"""

prints the sum of

two numbers which are 2 and 2

"""

print(2 + 2)

Python中的注釋類型

零基礎自學python、Python支持編寫簡單的單行注釋以及多行注釋。

單行注釋

一個簡單的單行注釋將以井號(#)字符開頭。Python運行時會忽略#字符后寫的任何文本,并將其視為注釋。

單行注釋

# This is a simple comment

print(2 + 2)

python3教程?print(2 + 3) # prints 5

多行注釋

Python沒有什么特別的東西可以寫多行注釋。要編寫它,我們可以編寫多個單行注釋。

我推薦這種形式的評論。

多行注釋

# This statement

python基礎教程廖雪。# prints the sum of

# two numbers which are 2 and 2

print(2 + 2)

我們可以利用未分配給變量的多行字符串文字(使用_三引號_)。Python會忽略未分配給任何變量的字符串文字,因此它不會影響程序執行。

Un-assigned string literal

"""

python編程入門,This statement

prints the sum of

two numbers which are 2 and 2

"""

print(2 + 2)

將有關在python中編寫注釋的問題交給我。

pygame教程、學習愉快!

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/2/176988.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息