Here is a question I wrote!!! Under the closed principle of satisfying function, the indefinite length parameter of the printing function is realized, and the execution time of the printing function is implemented.
Who can who can implement the following print function call method???
Import TimedefOuter (func):defInner (*args,**Kwargs): Start=time.time ()Print("*****") func (*args,**Kwargs) Time.sleep (0.5) Stop=time.time ()Print(stop-start)Print(*args,**Kwargs)returnInner@outerdefF (A, B):Print("11111") F (1,[12,156])
There's one more question. Think your solution is clumsy, the topic is to use a function to achieve a sequence of adjacent to the weight, the sequence can be a string, list, pairs tuples group.
The idea is: first the original so that the sequence of the implementation of the list conversion, and then proceed with the next comparison, if not the same will be append to a new list , if the same is skipped, and finally converted to the corresponding data type.
If there is a good idea please comment me thank you!
def func (squence): " squence can be string, tuple, list " = List (squence) = 0 = [] While cur < (len ( Mid)-2): if mid[cur]! = mid[cur+1]: lista.append (mid[cur]) cur+=1 Print(ListA) func ([1,22,22,33])
This is a I have not solved the face of the question!! Python decorator