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
|
example |
brief description |
| number |
1234, 3.14, 1.3e5,3+4j |
|
| string |
' zhn620 ', ' python ' |
|
| list |
[1, 2, 3],[' A ', ' B ', [' C ', 2]] | td>
| 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