is a very systematic ASP. NET sample tutorial? Lt; br> similar to Quickstart, But how detailed is it? Lt; br> you can name it like some books-"from entry to mastery? Lt; br> ASP. NET developer's cookbook
Chapter 1: Web form BasicsChapter 2: User ControlsChapter 3: Custom ControlsChapter 4: cachingChapter 5: mobile controlsChapter 6: ASP. NET application configurationChapter 7: State managementChapter 8: SecurityChapter 9: Debugging and error handlin
I never saw the decorator. Today I flipped through the cookbook and read it for a while.
20.1 obtain new default values in function calls
Task: After the def statement of the function is executed, Python calculates the default value for the optional parameter of the function, but only once.
For some functions, each time you want to call a function, the default value is calculated.
CodeAs follows:
Import copydef freshdefaults (F): "An F-encapsul
values clipped to 0Neg_clip = [nifn > 0Else0 forNinchMyList]Print('The negative number is replaced by 0, and the result:', Neg_clip)#Positive values clipped to 0Pos_clip = [nifN Else0 forNinchMyList]Print('The positive number is replaced by 0, and the result:', Pos_clip)" ">>> ================================ RESTART ================================>>> mylist = [1, 4, -5, ten,-7, 2, 3,-1] Negative number is replaced by 0, result: [1, 4, 0, 0, 2, 3, -5 0, 7,-0, 0, 1,]The recommended tool, Iterto
Problem: Remove duplicate elements from the sequence, but still leave the remaining elements in the same orderSolution:1. If a value in a sequence can be hashed (hashable), it can be resolved by using the collection and the generator.2, if the sequence is not hashed, want to remove duplicates, you need to modify the above code slightly:The function of the key parameter is to specify a function to convert the elements in the sequence into a hash type, so that duplicates can be detected."Python
Problem: Look for two dictionaries in the middle of the same place (same key, same value, etc.)Solution: Use the keys () or the items () method to perform common collection operations (such as seek a set, intersection, and difference sets)>>> a={'x': 1,'y': 2,'Z': 3}>>> b={'ww': 10,'x': 11,'y': 2}>>> A.keys () B.keys () #键的交集 {'y','x'}>>> A.keys ()-B.keys () #键的差集 {'Z'}>>> A.keys () |B.keys () #键的并集 {'ww','y','x','Z'}>>> A.items () B.items () {('y', 2)}>>> A.items ()-B.items () {('Z', 3), ('x',
fixed-length queue that automatically removes the oldest record when a new element is added and the queue is full: from Import deque>>> q=deque (maxlen=3)>>> q.append (1)>>> q.append (2 )>>> q.append (3)>>> qdeque ([1, 2, 3], maxlen=3)>>> Q.append (4)>>> qdeque ([2, 3, 4], maxlen=3)>>> q.append (5) >>> qdeque ([3, 4, 5], maxlen=3)>>>Although this can be done manually on the list (append, Del), this solution for the queue is much more elegant and runs much faster.If you do not specify a queue l
first. >>> import JSON >> > Dordereddict ([( " foo , 1), (" bar , 2), (" spam , 3), ( ' grok , 4)]) >>> Json.dumps (d) " {" foo ": 1," Bar ": 2," Spam ": 3," Grok ": 4} >>> Add: Ordereddict internally maintains a doubly linked list, which arranges the position of the keys according to the order in which they are added. The first newly added element is placed at the end of the list, and subsequent re-assignment of the existing key does not change the order of the keys.Note: The s
slice object s, you can get information about the object by S.start, S.stop, and S.step properties, respectively.>>> items=[0,1,2,3,4,5,6]>>> a=slice (2,4)>>> Aslice (2, 4 , None)>>> a.start2>>> a.stop4>>> a.step>>> b= Slice (1,5,2)>>> bslice (1, 5, 2)>>> b.start1>>> b.stop5>>> b.stepIn addition, you can map slices to a sequence of a specific size by using the indices (size) method. This returns a (start,stop,step) tuple in which all values have been properly restricted within the bounds (as a
; Format (text,'')'Hello World'>>> Format (text,'^20')'Hello World'>>> Format (text,'*>20')#other padding characters that are extra empty can be specified before the alignment'*********hello World'>>> Format (text,'=')'Hello world========='>>> Format (text,'%^20')'%%%%hello world%%%%%'>>>#when multiple values are formatted, the formatting code code can be used in the format () method>>>'{: >10} {: >10}'. Format ('Hello',' World')'Hello World'>>>‘{: >10} {:%^10}‘. Format(‘Hello' ,'World')' Hello%
Problem: Use regular expressions to match text patterns to identify the longest possible match to find the shortest possible matchWorkaround: Add after the * operator in the matching pattern. ModifierImportRe#Sample TextText ='computer says "No." Phone says "Yes."'#(a) Regex that finds quoted Strings-longest matchStr_pat = Re.compile (r'\"(.*)\"')Print(Str_pat.findall (text))#(b) Regex that finds quoted Strings-shortest matchStr_pat = Re.compile (r'\"(.*?) \"')Print(Str_pat.findall (text))>>> ==
Alpha to 0.5}endcg//the Ztest greater is set above, only the areas that are obscured are rendered. So the next place to render the area without occlusion. Zwrite onztest lequal//greater/gequal/less/lequal/equal/notequal/always/never/off default is LEqual if you want to draw the Z-value of the pixel The small remainder equals the value in the depth buffer, then replaces it with the new pixel color value. Cgprogram#pragma Surface Surf lambertsampler2d _maintex;struct Input {float2 uv_maintex;}; v
= tex2d (_maintex, In.uv_maintex); O. Albedo = C.rgb;o. Alpha = C.A;} ENDCG} FallBack "Diffuse"}Select the new Shader in the Material, and then drag the material to a point near the Sphere body, you will find the original near a point of the Sphere is a little farther Sphere covered!Unity provides a number of default render queues.Background: Background, first rendered, used for sky boxes, etc. Render Queue Value =1000Geometry: Geometry, default render queue, for most objects, opaque geometry U
:_cutoff is specified in the #pragma statement#pragma surface surf Lambert alphatest:_cutoffWhen Alphatest:_cutoff is specified, our shader becomes a transparent clipping shader. When the Alpha value of the fragment 2. Assign the channel value to O.alphaO.alpha = C.R;According to the above, I thought the workflow was like this.Float _cutoff=0.5o. Alpha = texture. Rif (O.alpha But looking at unity-generated shader code discovery is using the Clip () functionThis sentence in the box Alpha Test C
selected according to requirements.struct Appdata_base { float4 vertex:position; FLOAT3 Normal:normal; Float4 texcoord:texcoord0;}; struct Appdata_tan { float4 vertex:position; FLOAT4 tangent:tangent; FLOAT3 Normal:normal; Float4 texcoord:texcoord0;};3. Use the vertex color as the output in the surf () function.void Surf (Input in, InOut surfaceoutput o) {o.albedo=in.vertexcolor;}Full shader codeShader "Cookbookshaders/chapt7-1/vertexcolor" {Properties {_maintex ("Base (RGB
Smooth python and cookbook learning notes (2), pythoncookbook1. Value assignment of the packet splitting and decompression sequence of tuples
Any sequence (or iteratable object) can be decompressed and assigned to multiple variables through a simple assignment statement. The only premise is that the number of variables must be the same as the number of sequential elements.
1. Parallel assignment:
>>> X = (1, 2) >>> a, B = x # tuples >>> a1 >>> b2
2. U
Smooth python and cookbook learning notes (9), pythoncookbook1. Reduce the number of parameters of callable objects and use functools. partial to freeze Parameters
Use functools. partial () to fix one or more values to reduce the call parameters.
>>> Def spam (a, B, c, d ):... print (a, B, c, d)...> from functools import partial >>> s1 = partial (spam, 1) # set the value of a to 1 >>> s1 (2, 3, 4) 1 2 3 4> s1 (4, 2, 7) 1 4 2 7> s2 = partial (spam, d =
Smooth python and cookbook learning notes (5), pythoncookbook1. Random selection
Use the random module to generate random numbers in python.
1. Randomly select elements from the sequence and use random. choice ()
>>> import random>>> values = [1, 2, 3, 4, 5, 6]>>> random.choice(values)3>>> random.choice(values)3>>> random.choice(values)1>>> random.choice(values)1>>> random.choice(values)4
2. Retrieve the specified number of elements and use random. sa
Python cookbook (data structure and algorithm) to find the maximum or minimum N elements implementation method example, pythoncookbook
This example describes how to find the maximum or minimum N elements in python. We will share this with you for your reference. The details are as follows:
Problem:To find the maximum or minimum N elements in a collection
Solution:In the heapq modulenlargest()Andnsmallest()The two functions are exactly what we need.
>>
handle non-file-name strings.#example.py##Example of using Shell-wildcard style matching in list comprehensions fromFnmatchImportFnmatchcase as Matchaddresses= [ '5412 N CLARK ST', '1060 W ADDISON ST', '1039 W GRANVILLE AVE', '2122 N CLARK ST', '4802 N BROADWAY',]a= [addr forAddrinchAddressesifMatch (addr,'* ST')]Print(a) b= [addr forAddrinchAddressesifMatch (addr,'54[0-9][0-9] *clark*')]Print(b)>>> ================================ RESTART ================================>>> ['
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.