Python comments, python comments multiple lines

Source: Internet
Author: User

Python comments, python comments multiple lines

Annotations are used to describe the functions of the Code, the algorithms used, the code writers, and the creation and modification time.

Annotations are part of the code and play a complementary role in code description.

Python Annotation

A single-line comment in Python starts with #. A single-line comment can be placed on the annotated code line as a separate line, or after a statement or expression.

#Give you a chance to let you know meprint("Give you a chance to let you know me")say_what = "this is a demo" #at the end of a line

In Python, multiple-line comments use three single quotes (''') or three double quotes ("). In fact, this is the writing method of multiple-line strings, it is not a multi-line comment advocated by Python itself.

Python notes see: https://docs.python.org/3/reference/lexical_analysis.html#comments

# File name: test. py ''' this is a multi-line comment, using single quotes. This is a multi-line comment, using single quotes. ''' "Is a multi-line comment with double quotation marks. This is a multi-line comment with double quotation marks. """

Python also has some special annotations to complete some special functions, such as coding comments and platform comments.

Encoding notes:

#-*-Coding: UTF-8-*-print ("Hello, Python ");

From Python3, Python uses UTF-8 encoding by default, so the Python3.x source file does not require a special declaration of UTF-8 encoding.

See https://www.python.org/dev/peps/pep-0008/#source-file-encoding

Platform Note: To enable Python to run on a Windows platform, add the following comment at the beginning of the Python file.

#!/usr/bin/python

#! /Usr/bin/python describes the path of the Environment used by the program.

If you use a text editor for Python program editing comments, you can also use it for program debugging. The program is divided into several parts to comment out unnecessary code and focus on the Code logic currently written.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.