Gd_sehun
Links: http://www.imooc.com/article/2367
Source: MU-Class Network
1.
Read the code below to write the final value of A0,A1 to an.
A0=Dict(Zip((A,' B ',C,' d ',E),(1,2,3,4,5)))A1=Range(10)A2= [IForIinchA1ifIinchA0]A3= [A0[s] forsinchA0]A4= [IForIin A1 if I in A3]a5 ={i:i* i for I in A1 }a6 = [[,i*i for I in A1
/span>
2.
What do these two parameters mean: *args , **kwargs ? Why should we use them?
If we are not sure how many arguments we want to pass into the function, or if we want to pass the arguments as lists and tuples in the function, then it will be used *args if we do not know how many keyword parameters to pass into the function, or if we want to pass in the dictionary value as a keyword parameter **kwargs . argsand kwargs These two identifiers are used in a conventional way, and of course you can use *bob and **billy , but that's not quite right.
3.
What does the following mean: @classmethod , @staticmethod , @property ?
These are adorners (decorator). An adorner is a special function that either accepts a function as an input parameter and returns a function that accepts a class as an input parameter and returns a class. The @ tag is a syntactic sugar (syntactic sugar) that allows you to decorate a target object in a simple, easy-to-read manner.
@classmethod, @staticmethod, @property The objects used for these three adorners are functions defined in a class. The following examples show how they
4.
random = [Random.random () for I in range (100000)]
Produces a random number within (0-1), altogether 100,000
5.
Lambda functions
Lambda expressions, which are usually used when a function is needed, but do not want to bother to name a function, that is, an anonymous function
Lambda function: The primary purpose is to point a short callback function
Lambda [arguments]:expression
>>> A=lambdax,y:x+y
>>> A (3,11)
6.
RE module; Regular Expression Module
/span>
Python Interview 1