Home  >  Article  >  Backend Development  >  What symbols are used for single-line comments in Python code

What symbols are used for single-line comments in Python code

angryTom
angryTomOriginal
2020-02-11 11:19:2316720browse

There are many kinds of comments in python, including single-line comments, multi-line comments, batch comments, and Chinese comments are also commonly used. Python comments also have their own specifications. This article will introduce single-line comments in Python.

What symbols are used for single-line comments in Python code

What symbols are used for single-line comments in Python code

Use the pound sign "#" for single-line comments.

Python uses the pound sign (#) to indicate the beginning of a single-line comment. Code following the "#" sign until the end of the line will be ignored by the interpreter.

A single line comment is to comment a line of code in the program. In a Python program, just put the pound sign (#) before the content that needs to be commented. The content to the right of

print(1) #输出1

# will not be output during execution.

Execution result:

1

Recommendation:Python tutorial

The above is the detailed content of What symbols are used for single-line comments in Python code. 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