What are the comments in python?

爱喝马黛茶的安东尼
Release: 2019-06-19 13:44:20
Original
18390 people have browsed it

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
Copy after login

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
Copy after login

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
Copy after login

or

# -*- coding: utf-8 -*-
Copy after login

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!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!