Home >Backend Development >Python Tutorial >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!