stay python in , An object has three elements ,value,id and type.
“==” The main judgment is that of two objects value Are they the same? ,
“is” Also called identity operator , Will judge both ID Are they the same? .
read: Read and output all the contents of the file ;
readline: A line that reads the contents of the file ;
readlines: Read all the contents of the file , Return a list by row .
When the parameters of a function are uncertain , have access to args and kwargs,args No, key value ,kwargs Yes key value .
When we don't know how many arguments to pass to the function , For example, we pass a list or tuple to , We just use *args
When we don't know how many keyword parameters to pass , Use **kwargs To collect keyword parameters
match() The function only detects the beginning position of the string and the detected string match , If the match is successful, the result will be returned , Otherwise return to None;
search() The function looks for a pattern match throughout the string , Only to find the first match and then return an object with matching information , This object can be called by group() Method to get the matching string , If the string doesn't match , Then return to None.
if_suite if expression1 else else_suite
expression1 ： Judge the condition
establish Thread Example , Pass it a function
establish Thread Example , Pass it a callable instance of the class
The derived Thread Subclasses of , And create instances of subclasses
Use thread pool
Inheritance describes the relationship between things , When we define a class When , From an existing class Inherit , Properties of the parent class 、 Method , Will be inherited to subclass .
Flask yes Python Write a lightweight Web Application framework . Its WSGI The tool box uses Werkzeug , The template engine uses Jinja2.Flask Use BSD to grant authorization . Two of the environmental dependencies are Werkzeug and jinja2, This means it doesn't have to rely on external libraries . Because of this , We call it a lightweight framework .
Python The reference counting mechanism is used to manage the allocated memory .Python Each object of has a reference count , This reference count shows how many objects are pointing to it . When the reference count is 0 when , Free the memory of the object . To solve the problem of circular reference ,Python Provides “ Mark - eliminate ” Law , Objects used to release circular references .
stay python2 in ,range（100） It returns a list ,
stay python3 in ,range（100） It returns an iteratable object .
Functions can be passed as arguments in languages where decorators can be used
python Built in data types have reshaping （int）、 floating-point （float）、 The plural （complex）、 Boolean （bool）、 character string （str）、 list （list）、 Tuples （tuple）、 aggregate （set）、 Dictionaries （dict）、
__new__ It's an action that takes place before an object is created , The accepted parameters are cls, Responsible for the creation of objects ;
__init__ It's the action after the object is created , Perfect the properties of objects , The accepted parameters are self.
Objects are generated in new Done in .
with Method to open a file , We can complete the operation of the file , Close files automatically , Ensure the security of the file .
① Using generators generator;
② Iterator iterates ：for line in file
Iteratable object ： Can act directly on for The object of the cycle ;
An iterator is an object used for iterative operations , Iterators are iteratable objects . Simply speaking , An iterator can be next() Function calls and continuously returns the next value ;
The nature of a generator is also an iterator , The difference between iterators and iterators is that yield, The generator needs to use yield.
The essence of decorator is a function , It's just that the decorator's parameters don't look like normal functions , The argument to the decorator is a function , Its function is that it allows other functions to add additional functions without modifying the code , The return value of the decorator is also a function object . In development , We need to be open and closed , For functions already implemented , We will not modify it , At this point, we need decorators to extend it .
GIL（Global Interperter Lock） Global interpreter lock ,GIL yes Python Explain the level of lock , Solve the problem of multiple threads competing for resources in the interpreter （ Multiple threads compete for system resources , Are waiting for a part of the object to be de occupied , As a result, no one wants to unlock it first , Then wait for each other , The program can't go on ）.
First , Lists and tuples are collections that can store any data type ,
But tuples are immutable .
help Function is a built-in function , A detailed description of the purpose of a function or module .
dir() Function time python Built in functions for ,dir() When a function has no arguments , Returns the variables in the current range 、 List of types of methods and definitions , With parameters , Return the properties of the parameter 、 Method list
The answer is No . Variables with object circular references or global namespace references , stay Python Exit is often not released .
Dynamic replacement of properties at run time , It's called monkey patch .
see Day1*args,**kwargs The role of ？ How to use ？