Learn Python The Hard Way learning (2)-Comments and #

Source: Internet
Author: User

Annotations are very important in the program. They can be used to describe the code and temporarily invalidate some code. Let's see how to use Annotations:
[Python]
1. #-*-coding: UTF-8 -*-
2. # This is a comment.
3. # Anything after # is ignored by python.
4.
5.
6. print "I cocould have code like this." # this will also be ignored.
7.
8.
9. # You can also use # to invalidate the code
10. # print "This won't run ."
11.
12.
13. print "This will run ."

The first sentence must be added to the Chinese comments. There may be a question:
The first sentence also begins with #. Why does it play the role of setting encoding?
It can only be said that this is a habit of writing, used to set the file encoding method, does not affect the running of the program.

After running:
Root @ he-desktop :~ /Mystuff # python ex2.py
I cocould have code like this.
This will run.
Root @ he-desktop :~ /Mystuff #

Extra score exercise
1. Remember and figure out the role and pronunciation.
The general Chinese reading well number.

2. Check your program from the back.

3. Have you found any errors? If yes, correct it. Www.2cto.com

4. Read your program and see if there are any errors? If yes, correct it.
Read to ensure that annotations can be understood, I think.

Author: lixiang0522

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.