Python notes-First day

Source: Internet
Author: User

1. The output print function of Python is to enclose the output string in single or double quotes, but not in combination. For example, print (' Hello,world ') and print ("Hello,world") are the same. 2. Case sensitive. 3. Because indentation uses spaces, copying code is no longer so convenient. 4. I set tab in notepad++ to automatically convert to 4 spaces. 5. Integers are more convenient to use hexadecimal, which is denoted by a "0x" prefix plus a number. 6. Floating-point numbers are relatively large using the science and Technology Law, "e" means "10", for example, 1.23x109 is 1.23e9, or 12.3e8,0.000012 can be written 1.2e-5, and so on. 7. Single or double quotation marks appear in the string, using the escape character in front of the symbol \. 8.Python this type of variable itself is called Dynamic language, which corresponds to static language. Static languages must specify the variable type when defining the variable, and if the type does not match, an error is given. 9. In Python, constants are typically represented in all uppercase variable names, for example: PI = 3.14159265359. (But in fact Pi is still a variable, Python does not have any mechanism to guarantee that PI will not be changed, so, using all uppercase variable names to denote constants is only a customary usage, and if you must change the value of the variable pi, no one can stop you.) ) 10. There is also a division is//, called the floor in addition. The results only go to integer parts, such as:
>>> 10//3 3
11. If there are many characters in the string that need to be escaped, you need to add a lot of \, in order to simplify, Python also allows to use R ' ' to indicate that the inner string is not escaped by default
S1 = R'hello,jack! '  = r' 'hello,jack! " " Print (S1) Print (S3)

Where the S1 and S3 outputs are the same.

12. If there is a lot of line wrapping inside the string, written in a line is not good to read, in order to simplify, Python allows the "..." format for multiple lines of content 13. There is no limit to the integer size. In fact, the floating point number is not ~ 14. We usually write these two lines at the beginning of the file:
# !/usr/bin/env Python3 # -*-coding:utf-8-*-

The first line of comments is to tell the Linux/os x system that this is a python executable and the Windows system ignores this comment;

The second line of comments is to tell the Python interpreter to read the source code according to the UTF-8 encoding, otherwise the Chinese output you write in the source code may be garbled.

This is my summary note, but the content is from the official website of Liaoche.

Python notes-First day

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.