Home>Article>Backend Development> What do python comments mean?

What do python comments mean?

(*-*)浩
(*-*)浩 Original
2019-07-04 09:07:30 7863browse

Comments are the explanation of the program code. When writing a program, you need to use comments appropriately to facilitate yourself and others to understand the role of each part of the program. When executed, it is ignored by the Python interpreter and therefore does not affect the execution of the program.

What do python comments mean?

#Python supports single-line comments and multi-line comments, as shown below. (Recommended learning:Python video tutorial)

Python single-line comments start with #. Single-line comments can be placed as a separate line above the commented line of code, or after a statement or expression.

#Give you a chance to let you know me print("Give you a chance to let you know me") say_what = "this is a demo" #at the end of a line

Multi-line comments in Python use three single quotes (''') or three double quotes ("""). In fact, this is the way to write multi-line strings, not Python itself. Multi-line comments are advocated.

# 文件名:test.py ''' 这是多行注释,使用单引号。 这是多行注释,使用单引号。 ''' """ 这是多行注释,使用双引号。 这是多行注释,使用双引号。 """

There are also some special comments in Python to complete some special functions, such as: coding comments, platform comments.

Coding comments:

# -*- coding: UTF-8 -*- print ("你好,Python");

Starting from Python3, Python uses UTF-8 encoding by default, so the source files of Python3.x do not need to specifically declare UTF-8 encoding.

For more Python related technical articles, please visitPython TutorialColumn for learning!

The above is the detailed content of What do python comments mean?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn