[first launch in the whole network] a complete set of concise Python syntax, with detailed knowledge points and mind map! [highly recommended collection!]

Posted by nikbone on Fri, 04 Mar 2022 18:27:39 +0100

catalogue

Three sentences you should get when learning Python!

Keep up with the trend, not follow the trend!

Taking refuge in the boss is not opportunistic!

Earning benefits is not eager for quick success!

The full set of Python syntax is coming!

Understanding the concept of python

Software installation of python

Pycharm

anaconda

Skills summary of getting to know python

Basic grammar of python

Knowledge point thought map

input function

Those holes in basic grammar

Conditional loop of getting to know python for the first time

Knowledge point thought map

Conditional statement case

Circular statement case

break and continue

range (num) function

Conditional cycle those pits

The tuple list of python

Knowledge point thought map

tuple

Access tuple

list

Dictionary collection for beginners in Python

Knowledge point thought map

Create dictionary

Modify dictionary

Dictionary built-in function

Traversal dictionary

aggregate

Those holes in the dictionary

Function module of Python

Knowledge point thought map

Define function

Anonymous function

An introduction to Python: object oriented (Part 1)

First knowledge of Python: object oriented (Part 2)

Knowledge point thought map

Detailed grammar case

File operation of Python (Part 1)

File operation of Python (Part 2)

Knowledge point thought map

operation

An introduction to Python exception handling

Knowledge point thought map

Introduction to exception handling

Regular expression of Python (end)

Learning is endless, welcome to pay attention: Wang xiaowang-123, take you to learn together!

Every word

Three sentences you should get when learning Python!

Keep up with the trend, not follow the trend!

Python is a popular programming language in recent years. How hot is it? Occasionally, WeChat official account is opened, and the Python training camp is popped up below the page. It opens up a circle of friends and finds that there is a course recommended to study Python. It opens CSDN and finds that the first list is Python recommendation. It is said that the influence of Python is still relatively large at present, which is closely related to the propaganda efforts of Python community.

How many people are learning Python at present? Who are those people learning Python? As for this question, I don't think there is an accurate answer, because the number of people learning Python is increasing every day, and learning Python is paid attention to by more and more people, so the best answer to this question is when everything is going on! From primary school, some people began to teach python programming thinking. Some areas even included Python in the entrance examination. Liberal arts majors are also learning python, from primary school students to college students; From non professional to professional; From loving to being good at, these are enough to prove that Python is not wrong!

The upsurge of all people learning Python has already sprung up. Don't say much. Go and learn!

Taking refuge in the boss is not opportunistic!

Everyone's learning will have a confused period: how to learn, how to learn, and what resources are there to learn? For a beginning programming learner, if you don't have a professional teacher to guide you to learn, the learning route may be more tortuous. For the beginning of learning python, you should find a suitable route. It's best to start from the basic and learn slowly and have a more detailed plan. That's why I want to write this article, To those Python learners who used to be confused and have dreams like me.

I always believe in one sentence: Please always remember that every step of the road is worth it! There is no regret in life. Even if you miss it, you should believe that the next meeting will be more wonderful!

Earning benefits is not eager for quick success!

Let me think of another sentence: only economic independence can make the soul tall and straight!

What can learning Python do? If you can't add a chicken leg to your life, will the student party love it so much? If you can't put wings on your future? Will professionals like it so much? If you can't put a halo on your dream? Can it fire?

So learning must have output. Everything you learn can make money. As for how to earn benefits, it's your own business. After learning Python, you can be a crawler, you can do data analysis, you can do automated office, and you can do a lot of things. After learning a certain length, many people feel very confused and don't know how to start. At this time, you can obtain money through technology. There must be a transition period for the conversion of knowledge into money, which can continuously improve your professional ability.

Originally, I wanted to start with technology directly, but I still wrote these three sentences. I hope our life should not only have boring code, but also have a happy life - poetic life with the left hand and code life with the right hand!

Warm tip: all blue fonts of this article can be clicked, and you can jump to the corresponding article label.

 

The full set of Python syntax is coming!

I wrote a column before A series of articles on getting to know Python At that time, when I finished updating this column, I found that not many keywords were clicked, because what I wanted was a full set of Python syntax, so if there was a structure, I had to sacrifice the heat of traffic. The smell of wine is not afraid of the depth of the alley. Today's article will bring it back to the Jianghu! Become famous in World War I!

Understanding the concept of python

First, learn python. What is Python? In fact, I have introduced it in great detail in this article. You can click in to read it!

In my cognition, I think if you want to learn a thing well, you must know its nature, and then know its reason!

Know yourself and know the enemy, then you can win every battle. What you said is not wrong!

Software installation of python

Pycharm

1. PYcharm professional edition has the most abundant functions. Compared with the Community Edition, PYcharm professional edition adds more advanced functions such as Web development, Python We framework, Python analyzer, remote development, supporting database and SQL.
2. The community edition of pycharm does not have such functions as Web development, Python We framework, Python analyzer, remote development, database and SQL support.
3. The professional version can be used normally only after we pay for the activation code, which is suitable for the development of the company's projects and some normal operations. As a community version, we can use it for free. This is suitable for learners for academic exchanges and relevant programming educators.

anaconda

1. anaconda (official website) is a distribution version that can easily obtain packages, manage packages, and uniformly manage the environment. Anaconda contains more than 180 science packages and their dependencies, including conda and Python.
2. anaconda has open source, simple installation process, high-performance use of python and R language, and free community support.
3. We can download anaconda as the compilation environment of our python. We can completely solve these problems in the process of learning Python syntax.


Click the article to enter the detailed installation tutorial, waiting for you. If you want to be good at it, you must first sharpen its tools

Skills summary of getting to know python

The development software we use: pychart editor has some skills. Previously, it provided a lot of skill guides in this article and distributed resource benefits to many small partners. Here, I will disclose it to my fans and partners all over the network in advance. If the fans exceed 10000 +, I will write a resource benefit release article, Dedicate all my resources, hahaha, looking forward to 600 GB of documents, videos and codes!

Basic grammar of python

Knowledge point thought map

input function

name=input("Please enter your name:")
age=int(input("Please enter your age"))
print(name)
print(age)

Please click the title for detailed syntax!

Those holes in basic grammar

As for the detailed grammar introduction, please move to the article link and click the title

In case of trouble, stand up and give up without advance. Notes are very important!!!

For a programmer or IT worker with development potential, annotation must be very important. We must have our own code style, but we must annotate. As a beginner, we must develop the habit of commenting code, which is conducive to our future code for others to view. This is one of the habits that a programmer must develop.

When working, we should also pay attention to that when we are working on a project, any project needs to be completed by a team, so the code you are responsible for needs comments, which is very important for others to understand!

Naming is also very important. Standardized naming is also very important for our code. Every company will have its own naming rules. We need to develop this habit and quickly adapt to this environment in the future.

The most important part of basic grammar is the research of string. The following is a detailed thought map of string knowledge points:

Conditional loop of getting to know python for the first time

Knowledge point thought map

Conditional statement case

a=int(input("First number input: "))
b=int(input("Enter the second number: "))
if a>b:
    print("The maximum value is:%s"%a)
    if a>=100:
        print(a*a)
elif a==b:
    print("Binary equality is:{}",format(a))
else:
    print("The minimum value is:%s"%b)

Circular statement case

magicians=['alice','david','carolina']
for magician in magicians:
  print(magician)
current_number=1
while current_number<=5:
  print(current_number)
  current_number+=1

break and continue

for letter in "python":
	if letter=="h"
		break
		
var=10
while var>0:
	var-=1
	if var==5:
		break
		
for letter in "python":
    if letter=="h":
        continue 

range (num) function

range(start,stop,step)
start Represents the starting value, and stop Represents the termination value, step Representative process if yes
range(0,10,2)
>>>2,4,6,8
a=list(range(1,4))
print(a)
>>>
[1,2,3]
There is no 4 print out here because range Characteristics of function
 The last parameter can never be printed out

 

Conditional cycle those pits

For conditional judgment, the syntax of if and Elif is the easiest to ignore. When we want to execute multiple judgments, we need to write multiple if statements, but if Elif else can only execute the correct result once, so we need to understand this. In addition, for loops, we should set break and continue according to specific actual scenarios.

The tuple list of python

Knowledge point thought map

tuple

Create tuple

tup=("wang","xiao","wang");
tup1=();
tup2=("wang",)

Note that tuple is an object that cannot be modified. You need to remember this!!!

Access tuple

Tuple access requires a deep understanding of the index and how to understand the index. You may feel it by looking at this case

tup=["wang","xiao","wang"]
print(tup[:2])
print(tup[0])
print(tup[1:])
>>>
['wang', 'xiao']
wang
['xiao', 'wang']

1. For python string, if "p" is obtained, it must be [0]
2. If I want to get "n", it can be either [5] or [- 1]
3. If I want to take "py", [0:2] or[:2]
4. If I want to get "on", [- 2:] "negative index is used here"

list

In fact, the idea of creating a list is similar to that of creating a tuple, but the difference is that the list is [], and the tuple is: ()

Variable title() ~ initial capital

Variable append() ~ add

Variable remove() ~ delete

index (element) ~ returns the position number of the first occurrence of the element

pop ([i]) ~ returns the value corresponding to the parameter position and deletes it

Variable sort(reverse=Ture) in descending order; False is in ascending order

Update, insert, modify and delete are the same as tuple operations. Other lists can be embedded in the list

Dictionary collection for beginners in Python

Knowledge point thought map

Create dictionary

a = {key1 : valuel, key2 : value2 }

Creating a dictionary is the data type we need for daily development. Compared with the dictionary, we still use more dictionaries. We still need to have a certain understanding of how to operate the dictionary

Modify dictionary

a["python"]=99

Delete dictionary

del a["python"] 

Dictionary built-in function

dict={}
dict["python"]=100
dict["ipython"]=101
# del dict["python"]
print(dict)
print(len(dict))
print(str(dict))
print(type(dict))

Traversal dictionary

Use keys () to traverse all the values in the dictionary

dict={}
dict["python"]=100
dict["ipython"]=101
for a in dict.keys():
    print(a)

Use sorted () to sort the keys inside, which is in alphabetical order

Use values () to traverse all the values in the dictionary

dict={
    "a":100,"b":15,"y":85,"c":55
}
print(list(dict.values() ))

aggregate

# Perform some set operations with set
a=set("1,2,3,4")
b=set("3,4,5,6")
print(a-b)
print(a|b )
print(a&b)
print(a^b)

Those holes in the dictionary

For the dictionary, there is a get (x,y). This thing is easy to forget. We understand it this way. For example, when we get the dictionary, we output its value through the key x, but when we don't find the key X in this sequence, it will automatically create an X key, and then correspondingly pass the following value to the value of X. if the latter is not true, Then parameter Y is a useless parameter.

Note that the get () method here acquires the value in the dictionary, but does not change the value of the dictionary. If we want to have no such key in the dictionary, we will automatically create one and update the value in the dictionary. We need to use the setdefault(x,y) method, which is the same as the interpretation of get.

Function module of Python

Knowledge point thought map

 

Define function

def<Function name>(parameter list):
	Function statement
	return<Return value>

 

# Define a function without parameters
def hello_python():
    '''
    Print out a sentence
    :return: nothing
    '''
    print("hello,python!")
# Call this function
hello_python() 
# Define a function with parameters and return values
def all_return(T):
    '''
    Calculate sum
    :param num:
    :return: A number
    '''
    result = 0
    for i in T:
        result += i
    return result
print(all_return((1, 4)))

Anonymous function

Lambda function has certain advantages and convenience in our usual development. Especially when learning spark, we find the strength of lambda!

An introduction to Python: object oriented (Part 1)

First knowledge of Python: object oriented (Part 2)

Knowledge point thought map

 

Detailed grammar case

'''Simulate the daily life of dogs'''
class Dog():
    '''puppy'''
    def __init__(self,name,age):
        '''Initialize properties name and age'''
        self.name=name
        self.age=age
    def wang(self):
        '''Simulate the barking of a dog'''
        print(self.name.title()+"Woof, woof!")
    def shen(self):
        print(self.name.title()+"Stick out your tongue")
my_dog=Dog("junne",15)
you_dog=Dog("linux",16)
print("My dog's name is:"+my_dog.name.title()+".")
print("My dog is already:"+str(my_dog.age)+"Years old!")
my_dog.wang()
my_dog.shen()
print("\n Your dog's name is:"+you_dog.name.title()+".")
print("Your dog is already:"+str(you_dog.age)+"Years old!")
you_dog.wang()
you_dog.shen()

'''inherit'''
'''Define and use subclasses'''
class Car():
    """Car home"""
    def __init__(self, manufacturer, model, year):#Provide formal parameter information for instantiation
        self.manufacturer=manufacturer
        self.model=model
        self.year=year
        self.odometer_reading=0
    def get_descriptive_name(self):#Return information printing
        long_name=str(self.year)+" "+self.manufacturer+" "+self.model
        return long_name.title()
    def update_obometer(self, mileage):#Mileage increase
        if mileage>=self.odometer_reading:
            self.odometer_reading=mileage
            # print("this is a reasonable data!", str(self.odometer_reading) + "kilometers!")
        else:
            print("This is an unreasonable data!")
    def increament_odometer(self,miles):#Intelligent music addition
        self.odometer_reading+=miles
    def read_obometer(self):#Print mileage
        print("This is a new car. At present, the instrument shows that the journey is" + str(self.odometer_reading) + "Kilometers!")
class Bmw(Car):
    '''This is a subclass and the base class is Car'''
    def __init__(self,manufacturer, model, year):
        super().__init__(manufacturer, model, year)#This is a special function. Its function is to connect and associate parent and child classes
        # self.battery_size="6-cylinder 3.0T"
        self.Motor=Motor()#The motor instance is automatically created. Although no parameters are specified, the following function specifies
    # def motor(self):
    #     print("engine is" + str(self.battery_size))
class Motor(Bmw):
    def __init__(self,Motor_size=60):
        self.Motor_size=Motor_size
    def describe_motor(self):
        print("The engine parameters of this car are"+str(self.Motor_size)+"6 Cylinder, 3.0T Turbocharged, 225 KW.")


my_tesla=Bmw("bmw","535Li","2017 paragraph")
print(my_tesla.get_descriptive_name())
my_tesla.update_obometer(0)
my_tesla.read_obometer()
# my_tesla.motor()
print("*******************************")
my_tesla.increament_odometer(10)
my_tesla.read_obometer()
my_tesla.Motor.describe_motor()

In Python, everything is object-oriented. If you integrate the idea of object-oriented, you should be handy when designing code!

For detailed grammar, please click the title to learn!

File operation of Python (Part 1)

File operation of Python (Part 2)

Knowledge point thought map

operation

open(filename,mode="r",buffering=-1,encoding=None,errors=None,newline=None,closed=True,opener=None)
'''writelines()'''
'''The function writes multiline strings to a file'''
fo = open("Wang Xiaowang.txt","w",encoding="utf-8")
fo.writelines("hello,python!")
# Here, you can also write a list or other types
for i in range(5):
    line=fo.readline()
    print(line)
fo.close()
'''*****************'''
fo =open(r"Wang Xiaowang.txt",encoding="utf-8")
print(fo.readline())
fo.close()

As for the specific operation of the document, you can click the article, because there are too many involved, the simple introduction will lose the significance of other articles gathered here

An introduction to Python exception handling

Knowledge point thought map

Introduction to exception handling

In the actual development, we often encounter some examples of error reporting. Under the display page of pycharm, when we see a string of red English letters, there is an exception. At this time, if the children's shoes with better English can be solved by ourselves according to its prompts. However, English is the weakness of many children's shoes, but don't worry. At this time, you need to have a translation artifact. I use Netease Youdao dictionary, but sometimes we still encounter some rare expressions, so in this issue, let's take a look at some common error reports and solutions in the actual development process of Python.

try:
    a=str("Wang Xiaowang")+1233
    print(a)
except:
    print("Abnormal syntax error occurred!")

For details, please click the article title!

Regular expression of Python (end)

Regular expression is a text pattern, including ordinary characters and metacharacters. Although regular expression is cumbersome, it is powerful and widely used in Java, C + +, PHP, Python, c# and so on

When it comes to exception handling, the basic syntax of Python should be over, but I think regular expressions are widely used in Python or in other languages, so as a relatively complete set of Python syntax, I still wrote this article! For your study and reference!

'''Statistics of functions and variables in the specified file'''
import re
import sys
def tongjiFunc(s):
    r=re.compile(r"""
    (?<=def\s)
    \w+
    \(.*?\)
    (?=:)
    """,re.X |re.U)
    return r.findall(s)
def tongjiVar(s):
    vars=[]
    r=re.compile(r"""
    \b
    \w+
    (?=\s=)
    """,re.X|re.U)
    vars.extend(r.findall(s))
    re.compile(r"""
    (?<=for\s)
    \w+
    \s
    (?=in)""",re.X|re.U)
    vars.extend(r.findall(s))
    return vars
if len(sys.argv)==1:
    sour=input("Enter your file path:")
else:
    sour=sys.argv[1]
file=open(sour,encoding="utf-8")
s=file.readlines()
file.close()
print("Don't worry! gradual......")
print("file",sour,"The functions that exist in are:")
print("*********************************")
i=0
for line in s:
    i+=1
    function=tongjiFunc(line)
    if len(function)==1:
        print("line:",i,"\t",function[0])
print("**********************************")
print("file",sour,"The variables in are:")
print("******************************")
i=0
for line in s:
    i+=1
    var=tongjiVar(line)
    if len(var)==1:
        print("line",i,"\t",var[0])
print("It's over!!!!!")

 

Writing here, I find that it is a slow harvest. I hope this article can help all partners learning Python in the whole network. Your support will always be the biggest driving force of our output!!!

Learning is endless. Welcome to pay attention: Wang xiaowang-123, take you to study happily!

For the high-definition mind map of this article, if necessary, you can leave a message in the comment area: QQ email, automatic sending!!!!!!

Every word

Youth has a kind of persistence, called not giving up! Even if you can't overturn against the wind, you have to live in the sun!!