How to learn python entry?
Python novice learning route, Python entry should understand some basic computer programming terms. Python is a high-level scripting language that combines interpretation, compilation, interactivity, and object-oriented. Python is designed to be very readable. Compared with other languages, it often uses English keywords and some punctuation marks in other languages. , It has more distinctive grammatical structure than other languages.
1. Build the Python environment
How to build a Python development environment locally.
Python can be used on multiple platforms including Linux and Mac OS X.
You can enter the "python" command through the terminal window to check whether Python is already installed locally and the installed version of Python.
Unix (Solaris, Linux, FreeBSD, AIX, HP/UX, SunOS, IRIX, etc.)
Win 9x/NT/2000
Macintosh (Intel, PPC, 68K)
OS/2
DOS (multiple DOS versions)
PalmOS
Nokia mobile phones
Windows CE
Acorn/RISC OS
BeOS
Amiga
VMS/OpenVMS
QNX
VxWorks
Psion
Python can also be ported to Java and .NET virtual machines.
2. Python Chinese coding
In the previous chapters, we have learned how to use Python to output "Hello, World!", English is no problem, but if you output Chinese characters "Hello, World", you may encounter Chinese encoding problems.
3. Python basic syntax
The Python language has many similarities with languages such as Perl, C, and Java. However, there are some differences. Learning the basic syntax of Python allows you to quickly learn Python programming.
4. Python variable types
The value of the variable stored in memory. This means that when a variable is created, a space is created in memory.
Based on the data type of the variable, the interpreter allocates designated memory and decides what data can be stored in the memory.
Therefore, variables can specify different data types, and these variables can store integers, decimals, or characters.
What is an operator?
This chapter mainly explains the operators of Python. Take a simple example 4 +5 = 9. In the example, 4 and 5 are called operands, and "+" is called an operator.
The Python language supports the following types of operators:
Arithmetic Operator
Comparison (relational) operators
Assignment operator
Logical Operators
Bit operator
Member operator
Identity operator
Operator precedence
5. Python conditional statements
The Python conditional statement determines the code block to be executed by the execution result (True or False) of one or more statements.
6, Python loop statement
This chapter will introduce you to Python's loop statements, and programs are executed in order under normal circumstances.
Programming languages provide various control structures, allowing more complex execution paths.
7, Python While loop statement
The while statement in Python programming is used to execute a program in a loop, that is, to execute a program in a loop under certain conditions to handle the same task that needs to be processed repeatedly.
8. Python for loop statement
Python for loop can traverse any sequence of items, such as a list or a string
9, Python loop nesting
The Python language allows embedding another loop inside a loop body.
10. Python break statement
The Python break statement, just like in the C language, breaks the smallest closed for or while loop.
The break statement is used to terminate the loop statement, that is, if the loop condition does not have a False condition or the sequence has not been completely recursed, it will also stop executing the loop statement.
11. Python continue statement
The Python continue statement jumps out of this loop, and break jumps out of the entire loop.
The continue statement is used to tell Python to skip the remaining statements in the current loop, and then continue to the next loop.
12. Python pass statement
Python pass is an empty statement to maintain the integrity of the program structure.
pass does nothing, and is generally used as a placeholder statement.
Python Number
The Python Number data type is used to store numeric values.
The data type is not allowed to be changed, which means that if the value of the Number data type is changed, the memory space will be reallocated.
13, Python string
Strings are the most commonly used data type in Python. We can use quotation marks ('or ") to create strings.
14, Python list (List)
Sequence is the most basic data structure in Python. Each element in the sequence is assigned a number-its position, or index, the first index is 0, the second index is 1, and so on.
Python has 6 built-in types for sequences, but the most common are lists and tuples.
Operations that can be performed on sequences include indexing, slicing, adding, multiplying, and checking members.
In addition, Python has built-in methods for determining the length of the sequence and determining the largest and smallest elements.
The list is the most commonly used Python data type, and it can appear as a comma-separated value in square brackets.
The data items of the list do not need to have the same type
To create a list, simply enclose the different data items separated by commas in square brackets.
15, Python tuples
Python tuples are similar to lists, except that the elements of tuples cannot be modified.
Use parentheses for tuples and square brackets for lists.
Tuple creation is very simple, just add elements in parentheses and separate them with commas.
Python dictionary (Dictionary)
Dictionary is another variable container model, and can store any type of object.
Each key-value key=>value pair of the dictionary is separated by a colon:, and each key-value pair is separated by a comma, and the entire dictionary is enclosed in curly braces {}
16. Python date and time
Python programs can handle dates and times in many ways, and converting date formats is a common function.
Python provides a time and calendar module that can be used to format dates and times.
The time interval is a floating point decimal number in seconds.
Each timestamp is expressed in terms of how long has passed since midnight (epoch) on January 1, 1970.
There are many functions under Python's time module that can convert common date formats.
17, Python functions
Functions are organized, reusable, code segments used to implement a single or related function.
Functions can improve application modularity and code reuse. You already know that Python provides many built-in functions, such as print(). But you can also create a function yourself, which is called a user-defined function.
18. Python module
A Python module (Module) is a Python file that ends in .py and contains Python object definitions and Python statements.
Modules allow you to logically organize your Python code sections.
Assigning related code to a module can make your code more usable and easier to understand.
Modules can define functions, classes and variables, and modules can also contain executable code.
19. Python file I/O
This chapter only describes all the basic I/O functions. For more functions, please refer to the Python standard documentation.
Python File method
open() method
The Python open() method is used to open a file and return a file object. This function is required in the process of processing the file. If the file cannot be opened, an OSError will be thrown.
Note: Use the open() method to ensure that the file object is closed, that is, call the close() method.
The common form of the open() function is to receive two parameters: file name (file) and mode (mode).
20, Python exception handling
Python provides two very important functions to deal with exceptions and errors in the running of a python program. You can use this function to debug python programs.
Python OS file/directory method
The os module provides a very rich method for handling files and directories.
21, Python built-in functions
The Python development that only digs into the code is certainly not what the HR of major companies are rushing to ask for, find more projects and find more projects, practice more and practice more! Only by handwriting specific projects more by yourself can you make more mistakes and solve problems. After the position, you can step on the pit. The more pits you practice now, the more confident you will be when you talk about salary with HR in the future.