Want to know coursera full stack web development review? we have a huge selection of coursera full stack web development review information on alibabacloud.com
') dd[' key1 '] = ' abc ' Print (dd[' Key1 ']) # Key1 presence Print (dd[' Key2 ']) # Key2 does not exist, returns the default value CounterThe purpose of the counter class is to track the number of occurrences of a value. It is an unordered container type, stored in the form of a dictionary key-value pair, where the element is counted as the key and its count as value. The count value can be any Interger (including 0 and negative numbers). The counter class is similar to bags or multisets in o
effect AH # Yes: Using jion immediately after start will certainly turn the execution of the 100 tasks into serial, without a doubt, the result of the final n is certainly 0, is safe, but the problem is join immediately after #start: all the code within the task is executed serially, and the lock, The only part of the lock that modifies the shared data is the serial # order from the data security aspect, both can be achieved, but it is obvious that the lock is more efficient. From threading imp
inheritance order, there is a situation and py3 different, such as, where bar does not inherit object (classic Class), depth first, other cases, are breadth first # Py27class Bar (): def F1 (self): print (' Bar ') class A (bar): def f (self): print (' a ') class C (a): def f (self): print (' C ') class B (bar): def F1 (self): print (' B ') class D (b): def F1 (self): print (' d ') Class E (c,d): def f (self): print (' e ') e = e () e.
() function, printing the ' F function ' >>end # f function finished, then execute the INNER1 function inside the print (' End ') >> End # Finally execute the INNER2 function inside the print ( ' End ')4, with parameters of the adornerThe front of the adorner itself without parameters, if you want to write a parameter of the adorner, then we need to write a three-layer adorner, and the front of the adorner is not too standard, the following to write a comparison specification with parameters of
Python full stack development-Day10 decorator (closed function application), python-day10I. decorator
The decorator is an Application Scenario of closure functions.
What is a closure function? Let's recall:
Closure functions:
A function defined within a function. The function contains a reference to the external function scope (emphasizing that the reference to t
Python full stack development-Day9 function object, function nesting, namespace and scope, python-day9I. Function objects
1. functions are the first type of objects, that is, functions can be passed as data.
1 can be referenced 2 can be passed as a parameter 3 return value can be an element of function 4 can be used as a container type
Ii. Use this feature to ele
Python full stack Development 5. Several Common sorting algorithms and the data structure provided by the collections module, pythoncollections
During the interview, I often encounter some questions about the sorting algorithm. Here, I simply listed several of the most common sorting algorithms for you to learn. Maybe the interview will be useful in the future, t
Python thread pool and process pooling for concurrent application# thread pool requires imported module from Concurrent.futures Import threadpoolexecutor# process pool requires imported module from Concurrent.futures Import Processpoolexecutorimport time# test Function def task (ARG): print (ARG) time.sleep (1) # Instantiates a thread pool object with a maximum concurrency of 10pool= Threadpoolexecutor #pool. The submit parameter is a function and the parameter is passed for I in range:
Team7 Print(Queue_l.pop (0))8 Print(Queue_l.pop (0))9 Print(Queue_l.pop (0))Ten Print(Queue_l.pop (0)) One Print(Queue_l.pop (0)) A Print(Queue_l.pop (0))5, del, remove delete1 del # Simple Delete 2 hobbies.remove ('eat'# Simple Delete, and is the specified element to remove6. Len Lengthdetermine the default first length of the list hobbies=['play','eat',' Sleep ','study']print(len (hobbies))7. In contains 1 Determines if the sleep element exists with hobbies in the return true, return false
1, locals, globals1 def func (): 2 x = 13 y = 24print (Locals ()) # Prints the name in the local scope 5 Print# Prints the name in the global scope2.1 Print(123)2 "print (456)" #string3Eval"print (456)")#convert string to Python code to execute4 5 Output Results6123755W81exec("print (789)")91 num = 1+2+3Ten2 num = eval ("1+2+3")#execution will perform operation with return value One3Print(num) A4 -5 6 -1 num2 =exec("4+5+6")#executed, but no return value the2Print(num2) -3defmy
((6,6,6,6,6,8,8,8,8,8,8,))B=counter ({"Name": "Alex", "name": "Eve", "name": "Mary"})print (c) # Counter ({' H ': 6, ' F ': 6, ' G ': 4, ' d ': 3}) returned as a dictionaryprint (d) # Counter ({2:4, 3:4, 4:4, 1:1})print (e) # Counter ({8:6, 6:5})print (b) # Counter ({' name ': ' Mary '})three. Random1.random (+)#0到1之间的小数2.uniform (1.3)# more than 1 decimals less than 33.randint (1,5)# 1=4.randrange (1,10,2)# 1 to 10 odd Gu Tou regardless of tail5.choice ([1, "23°c", [4,5])# There must be an ind
, and so on, all variables, classes are marked during execution, and after execution, they are automatically reclaimed for a period of time without being called.class A:def __del__ (self):print ("666")a1=a ()a1.__del__10.__new__ Usageclass A:def __init__ (self):self.x=1print ("in init function") # Fifth Stepdef __new__ (Cls,*args,**kwargs): # The second step automates the __new__ methodprint (CLS) # Third Step print ("in new Function") # Fourth Stepreturn super (). __new__ (CLS) # Returns an obj
in iterable if condition) # Filter ModePros: 1. Save codeCons: Bad troubleshootingOverall: Generally used in a list deduction structure, in other ways can also, very complex list, list derivation is not constructedBuilt-in functions1.1 Scope-relatedA =33b = 22def func (): a = 1 print (Globals (), ' \ n ', locals ()) func ()1.21 Other relatedExecution of String type code Eval,exec,compliePrint (eval (' 1*2*3*4*5*6*7*8*9 ')) Li = "" For I in Range: print (i) "" "Exec (LI)1.22 input and o
))yield "222"Gen=func () # If there is yield in the function, this function is the generator function ret=gen.__next__ () # generator is essentially an iterator that can be executed directly __next__ () print (ret)(2) The difference between yield and return.#there is yield in the program, the function is the generator function, the access generator function, the function does not execute, returns a generator.# The generator executes __next__ and executes to the next yield.# yield and return are
collection (set)Collection, save a lot of data, can not repeat features: unordered, non-repeatable, content can be hashed, itself is not hash k = fRozenset (collection): It's going to be a hash.Increase:S.add (content) s.update ("content"): Iterative additionsDelete:S.pop (): Randomly deletes one and returns the deletion of that content s.remove (' specified element '): Delete the specified element, if not present will error S.clear (): Empty collection, if print out empty collection will show s
longer locally created. ? is the direct cause of the global aA=28Print (a)Func ()Print (a)# for variable data types you can go directly into the. But you can't change the address. Say it. Cannot assign a valueLST = ["Twist Vine", "Carina Lau", "James"]def func ():Lst.append ("? and") # can be accessed directly into the variable data type. But you can't change the address. Say it. Cannot assign a valuePrint (LST)Func ()Print (LST)2.nonlocal table? In the local field, adjust? Variable in the clas
corresponding to the same value, forming a dictionaryinfo='Alex's1={}v2=s1.fromkeys (info,222)print (v2) {'a'l'e ' ' x ': 222}4.5 get, returns value according to Key, if none is returned, the none can be modified info={'Alex': 123, 'a':'nishishei' ,'v': 555}#info= ' Alex 'v2= Info.get (567,222)print(v2)------222Because there is no key567, so return parameter, 2224.6 Pop (key, return default value)If there is no key, the default value is returnedIf there is, then delete and get4.7 Popitem ()R
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.