Home >Backend Development >Python Tutorial >What are the comments in python?

What are the comments in python?

爱喝马黛茶的安东尼
爱喝马黛茶的安东尼Original
2019-06-11 16:32:1218601browse

What are the comments in python?

What are the comments in python? The following is a summary of methods:

1. Python single-line comment symbol (#)

Single-line comments in python use # starting with

Example:

#this is a comment

2. Batch and multi-line comment symbols

Multi-line comments are made in triple quotes, for example:

Enter ''' ''' or """ """, insert the code to be commented in the middle

Related recommendations: "Python Video Tutorial"

3. The comment shortcut key of IDLE under Windows is Alt 3, and the uncomment key is Alt 4

4. python Chinese comment method

I wrote the script today When running, an error is reported:

SyntaxError: Non-ASCII character '\xe4' in file getoptTest.py on line 14, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

If there are non-ASCII characters in the file, you need to specify the encoding statement on the first or second line. Change the encoding of the ChineseTest.py file to ANSI and add the encoding statement:

Be sure to add this sentence on the first or second line:

#coding=utf-8

or

# -*- coding: utf-8 -*-

The above is the detailed content of What are the comments in python?. 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