Some basic knowledge in Python

Source: Internet
Author: User

1.Python is very good at code readability, in general, it is recommended to add a space between the operators and commas , adding a blank line between code blocks of different functions .

2. Everything in Python is object , in addition to the commonly used built-in objects (shown in table 1 below), there are a large number of standard library objects and extension library objects, the standard library is the Python default installation, but need to import before you can use the object. The extension library object will need to install the extension library first and then import and use the objects in it.

Table 1Python built-in objects

td> 
example brief description
number 1234, 3.14, 1.3e5,3+4j  
string ' zhn620 ', ' python '  
list [1, 2, 3],[' A ', ' B ', [' C ', 2]]
tuple (2,-5,6,7)  
dictionary {1: ' PYT Hon ', 2: ' Django ', 3: ' requests '}  
collection set (' abc '), {' A ', ' B ', ' C '}  
file f = open (' Test.txt ', ' RB ')  
boolean True, False  
null type None  
Programming Unit function (defined with DEF), Class (defined using Class)  

In Python, it is not necessary to declare variable names and their types in advance, to assign values directly to create object variables of various types, and the types of variables can be changed at any time.

>>>x = 3

>>>x = ' hello,world! '

>>>x = [1, 2, 3, 4, 5]

>>> isinstance (3, int) #内置函数isinstance () is used to test whether the object specifies an instance of the type, 3 is an int, and returns a true value.
True

Some basic knowledge in Python

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.