Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the necessary knowledge points for entry into Python?

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "What are the knowledge points that must be seen when getting started with Python". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "What are the knowledge points that must be seen in Python?"

1. Python version selection

Choose Python 3.5 or above for learning: Because Python2 will stop official maintenance in 2020, and Python 3 before version 3.5 still has some defects in performance, Python 3.6 and Python 3.7 are recommended here.

2. Unique string expressions

Python uses '(single quotes) and "(double quotes) to represent strings. Unlike Perl, Unix Shell, Ruby, Groovy, etc., the two symbols work the same. In general, if double quotes appear in a string, single quotes are used to represent the string; otherwise, double quotes are used. If none of them appear, choose according to personal preference.

3 Types of Python

Python uses a dynamic typing system. Python doesn't check whether an object has a called method or attribute at compile time, but does so at runtime. So an exception may be thrown when manipulating an object. Python, however, prohibits operations that are not explicitly defined, such as adding numbers to strings. Like other object-oriented languages, Python allows programmers to define types.

4. Expressions of Python functions

Python functions support recursion, default parameter values, and variable parameters, but not function overloading. To enhance readability of the code, you can write "Documentation Strings"(or docstrings for short) after the function, which are used to explain the function's role, the type and meaning of the parameters, the return value type and value range, etc. You can use the built-in function help() to print out help for using the function.

5. Indented expressions in Python

Python developers deliberately make programs that violate indentation rules impossible to compile, in order to force good programming habits on programmers. And Python uses indentation to indicate the beginning and exit of a block (the Off-side rule), rather than curly braces or certain keywords. Increasing indentation indicates the beginning of a statement block, while decreasing indentation indicates the exit of a statement block. Indentations became part of the grammar.

Python assignment operators

7. Python common control statements

If statement, which runs the statement block when the condition holds. Often used in conjunction with else, elif(equivalent to else if).

For statements traverse iterators such as lists, strings, dictionaries, and collections, processing each element of the iterator in turn.

While statement, which loops through a block of statements when the condition is true.

The try statement, used in conjunction with except,finally, handles exceptions that occur during program execution.

class statement, used to define the type.

Def statements, used to define methods for functions and types.

Pass statement, indicating that this line is empty and does not run any operations.

assert statement, used to test whether the running conditions are met during the debugging phase of the program.

With statement, syntax defined after Python 2.6, runs blocks of statements in a scenario.

raise statement, creating an error.

import statement to import a module or package.

The from import statement imports a module from a package or imports an object from a module.

The import as statement assigns the imported object to a variable.

The in statement determines whether an object is in a string/list/tuple.

At this point, I believe that everyone has a deeper understanding of "what knowledge points must be seen in Python", so let's actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report