Home  >  Article  >  Backend Development  >  What symbol does Python use to represent comments?

What symbol does Python use to represent comments?

尚
Original
2019-06-27 13:55:5024089browse

What symbol does Python use to represent comments?

Single-line comments in python start with #.

#!/usr/bin/python
# -*- coding: UTF-8 -*-
# 文件名:test.py
# 第一个注释
print "Hello, Python!"  # 第二个注释

Output result:

Hello, Python!

Comments can be at the end of the statement or expression line:

name = "Madisetti" # 这是一个注释

Multi-line comments in python use three single quotes (''') or three double quotation marks (""").

#!/usr/bin/python
# -*- coding: UTF-8 -*-
# 文件名:test.py
'''
这是多行注释,使用单引号。
这是多行注释,使用单引号。
这是多行注释,使用单引号。
'''
"""
这是多行注释,使用双引号。
这是多行注释,使用双引号。
这是多行注释,使用双引号。
"""

For more Python-related technical articles, please visit the Python Tutorial column to learn!

The above is the detailed content of What symbol does Python use to represent comments?. 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