In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you how to learn the introduction to python, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to understand it!
1. Build the Python environment
How to build a local Python development environment.
Python can be applied to multiple platforms, including Linux and Mac OS X.
You can enter the "python" command through the terminal window to see if Python and the installed version of Python are installed locally.
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 phone
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 section, we have learned how to use Python to output "Hello, World!". There is no problem with English, but if you output the Chinese character "Hello, World", you may encounter Chinese coding problems.
3. Basic syntax of Python
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 type
The value of the variable stored in memory. This means that a space is opened up in memory when you create a variable.
Based on the data type of the variable, the interpreter allocates the specified memory and determines what data can be stored in memory.
Therefore, variables can specify different data types, and these variables can store integers, decimals, or characters.
What is an operator?
This section focuses on the operators of Python. Take a simple example: 4 + 5 = 9. In the example, 4 and 5 are called operands, and "+" is called operators.
The Python language supports the following types of operators:
Arithmetic operator
Comparison (relational) operator
Assignment operator
Logical operator
Bit operator
Member operator
Identity operator
Operator precedence
5. Python conditional statement
A Python conditional statement is a block of code that determines execution by the execution result of one or more statements (True or False).
6. Python loop statement
This chapter will introduce you to the loop statement of Python, and the program is normally executed sequentially.
Programming languages provide a variety of control structures that allow for more complex execution paths.
7. Python While loop statement
In Python programming, while statements are used to loop a program, that is, under certain conditions, a section of the program is executed in a loop to handle the same task that needs to be repeated.
8. Python for loop statement
The Python for loop can iterate through any sequence of items, such as a list or a string
9. Python loop nesting
The Python language allows you to embed another loop in the body of a loop.
10. Python break statement
The Python break statement, as in C, breaks the minimum closed for or while loop.
The break statement is used to terminate the loop statement, that is, if the loop condition has no False condition or the sequence has not been completely recursive, it will stop executing the loop statement.
11. Python continue statement
The Python continue statement jumps out of the loop, and the break jumps out of the entire loop.
The continue statement is used to tell Python to skip the rest of the current loop and then proceed 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 (digital)
The Python Number data type is used to store numeric values.
The data type is not allowed to be changed, which means that if you change the value of the Number data type, 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 a string.
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, with the first index 0, the second index 1, and so on.
Python has built-in types for six sequences, but the most common are lists and tuples.
Operations that can be performed in a sequence include indexing, slicing, adding, multiplying, and checking members.
In addition, Python has built-in methods to determine the length of the sequence and to determine the largest and smallest elements.
The list is the most commonly used Python data type and 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 tuple
Tuples in Python are similar to lists, except that the elements of tuples cannot be modified.
Tuples use parentheses and lists use square brackets.
Tuple creation is simple, just add elements in parentheses and separate them with commas.
Python Dictionary (Dictionary)
Dictionaries are another variable container model and can store objects of any type.
Each key value key= > value of the dictionary is divided by a colon: split, each key value pair is divided by a comma, and the whole dictionary is included in curly braces {}
16. Python date and time
Python programs can process dates and times in many ways, and converting date formats is a common feature.
Python provides a time and calendar module that can be used to format dates and times.
The interval is a floating-point decimal in seconds.
Each timestamp is expressed in terms of how long has elapsed since midnight on January 1, 1970.
There are many functions under Python's time module that can convert common date formats.
17. Python function
A function is a code snippet that is organized, reusable and used to implement a single, or associated function.
Functions can improve the modularity of the application and the reuse of the code. You already know that Python provides many built-in functions, such as print (). But you can also create your own functions, which are called user-defined functions.
18. Python module
The Python module (Module), an Python file that ends with .py, contains Python object definitions and Python statements.
Modules allow you to organize your Python code snippets logically.
Assigning relevant code to a module can make your code easier to use and easier to understand.
Modules can define functions, classes, and variables, and modules can also contain executable code.
19. Python file iBandO
This chapter only deals with all the basic Icano functions. For more functions, please refer to the Python standard documentation.
Python File (file) method
Open () method
The Python open () method is used to open a file and return a file object, which is needed during the processing of the file, and throws an OSError if the file cannot be opened.
Note: when using the open () method, be sure to close the file object, that is, call the close () method.
The common form of the open () function is to take two parameters: the file name (file) and the pattern (mode).
20. Python exception handling
Python provides two very important functions to handle exceptions and errors that occur when python programs are running. You can use this feature to debug python programs.
Python OS file / directory method
The os module provides a wealth of methods for working with files and directories.
21. Python built-in functions
Python development, which only knows how to knock on the code, is certainly not what HR of the major companies are looking for. Find more projects, practice more and practice more! Only by writing more specific projects on your own can you make more mistakes, solve problems, and step on the job after the position. The more you practice now, the more confident you will be when you talk about salary with HR later.
The above is all the contents of the article "how to get started with python". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.