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

What symbol does Python use to represent comments?

Release: 2019-07-08 09:06:41
Original
24132 people have browsed it

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!"  # 第二个注释
Copy after login

Output result:

Hello, Python!
Copy after login

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

name = "Madisetti" # 这是一个注释
Copy after login

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

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

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template