Python What is it? ? Briefly describe the advantages and disadvantages ?
Python It is an object-oriented interpretive computer programming language , It is a combination of interpretability , Compilability , Interactive and object oriented scripting language .
advantage ： Open Source , Free Admission , simple , studies of the Book of Changes , Portability , Scalable , Easy to maintain , High development efficiency .
shortcoming ： Slow running speed , Code cannot be encrypted .
Python How is it explained ?
Python It's an explanatory language , Its source code can be run directly .Python The interpreter converts the source code into an intermediate language , Then translate it into machine code and execute it .
What is? PEP8?
PEP8 Is a programming specification , Some suggestions to make the program more readable .
Python How is memory managed ?
1） Reference counting mechanism ：Python Internal use reference count , To keep track of objects in memory .
2） Garbage collection mechanism ： When the reference count of an object returns to zero , It will be disposed of by the garbage collection mechanism ;
Recycle garbage collector , Ensure that the circular reference object is released .
3). Memory pool mechanism ：
Python Provides a garbage collection mechanism for memory , But it puts unused memory into the memory pool instead of returning it to the operating system :
Pymalloc mechanism ： To speed up Python Efficiency of implementation ,Python A memory pool mechanism is introduced , Used to manage the request and release of small memory .
about Python object , Such as integers , Floating point sum List, Each has its own private memory pool , Objects do not share their memory pool . That is to say, if you allocate a large number of integers , The memory used to cache these integers can no longer be allocated to floating-point numbers .
Python The decorator is a function , yes Python Unique changes in , It makes it easier to modify functions . It can make the function without modifying its own function definition , Dynamic generation of additional functions .
What is? Python Ornament ?
Python Decorator is a function , yes Python Unique changes in , It makes it easier to modify functions . It can make the function without modifying its own function definition , Dynamic generation of additional functions .
iterator , generator
Iteratable object ： have access to for-in Traversal object , They are all iterative objects
stay Python If an object has __iter__( ) Method or __getitem__( ) method , The object is said to be iterative （Iterable）; among
__iter__( ) The purpose of the method is to make the object usable for ... in Loop traversal ,__getitem__( )
The method is to let the object pass through the “ Instance name [index]” To access elements in an instance . let me put it another way , Only one of the two conditions is satisfied , It can be said that the object is iterative . Obvious list List, tuple Tuple, Dictionaries Dictionary, character string String All data types are iterative .
iterator ： Iterators are a way to access collection elements . Be able to use for-in Traverse , And can be used next Function to iterate
stay Python If an object has __iter__( ) Methods and __next__( ) method , This object is called an iterator （Iterator）; among __iter__( )
The method is to make the object available for ... in Loop traversal ,__next__( )
The method is to let the object pass through the next( Instance name ) Access the next element . be careful ： Both methods must be available at the same time , Can be called iterator . list List, tuple Tuple, Dictionaries Dictionary, character string String Although the data types are iterative , But none of them are iterators , Because none of them has next(
) method .
A function that references a free variable is a closure . The referenced free variable exists with this function , Even if it has left the environment that created it, it is no exception .
What's the difference between arrays and tuples ?
The difference between arrays and tuples ： The contents of the array can be modified , The tuple content is read-only . in addition , Tuples can be hashed , For example, as a keyword in a dictionary .
Class methods and static methods
method： Call by instance , You can refer to any property or method within a class
classmethod： No instantiation is required , You can call class properties and class methods , Unable to get normal member properties and methods
staticmethod： No need to instantiate , Cannot get any properties and methods inside the class , A completely independent method
Python What built-in types are available ?
integer (int), character string (str), tuple (tuple), Boolean (bool), aggregate (set), list (list), Dictionaries (dict)
What are dictionary derivation and list derivation ?
They are syntax structures that make it easy to create dictionaries and lists .
How do parameters pass by value and reference pass ?
Python Everything in is a class , All variables are references to an object . The value referenced is determined by the function , So it can't be changed . But if an object can be modified , You can change the object .
Python In lambda What is it? ?
This is an anonymous function , It is often used for a single expression in code .
Python In pass What is it? ?
pass Is a place holder , Used to indicate blank space , Not executed .
12,Python The difference between shallow copy and deep copy ?
copy.copy() Light copy ： Object copied , But the value of the copy object is still the value pointing to the original object （ Equivalent to citation ）, Modify the elements of the copy object , The value of the copied object is also modified .
copy.deepcopy() Deep copy ： It's not just copying objects , It also copies the elements in the object , Got a whole new object , Completely independent of the copied object ; But it takes time and space to sacrifice .
13,Python What are the modules and packages in ?
stay Python in , Module is a way to build a program . every last Python Code file is a module , Other modules can be referenced , Such as objects and properties .
One contains many Python The code folder is a package . A package can contain modules and subfolders .