Ideas
A helical matrix is a spiral matrix whose number starts with the first line to the right, and the downward becomes larger,The left is bigger, the upward is bigger, and so the loop goes.The helical matrices are represented by two-dimensional
What is an iterator?An iterator is a simple object with the next method, and of course implements the __ITER__ function. An iterator can iterate over the value of a sequence, and the next method throws a Stopiteration exception when there is no
1. List deduced form of writing:
An expression for variable in list or an expression for variable in list if condition
2. Examples:
Copy Code code as follows:
#!/usr/bin/python
#-*-Coding:utf-8-*-
Li =
Copy Code code as follows:
#-*-Coding:utf-8-*-
Class Heap (object):
@classmethoddef parent (CLS, i):"" "Parent node Subscript" "return int ((i-1) >> 1);
@classmethodDef left (CLS, i):"" "" "The Left son subscript" "Return (I
Copy Code code as follows:
# Compare two strings if the difference returns the first different position
# if the same return 0
def cmpstr (str1, str2):
Col = 0
For C1, C2 in Zip (str1, str2):
if C1 = = C2:
Col + 1
Continue
else:
Break
Recently learning Python, so I wrote a script to crawl discuz! username in Python, the code is very small but very rubbing. The idea is simply to match the title and then extract the user name to write to the text document. The program to Baidu
Copy Code code as follows:
Import socket
Import re
'''Guangdong Provincial Public Security Bureau entry-Exit government service network passport, pass processing progress inquiries.Analyze URL format for http://www.gdcrj.com/wsyw/tcustomer/
Copy Code code as follows:
Import OS # # for Os.path.isfile ()
def dealline (line):Print (line) # # for line I can do a lot of things
Def getfilename ():return input, ' please input file name (input exit () for exit): '. Strip ()
Class
deleting files
Copy Code code as follows:
Os.remove (filename) # filename: "File name to delete"
Possible causes of an exception:
(1) filename does not exist(2) The filename file, no permission to operate or read-only.
There is a demand on the line, formatted, to find a continuous suit from a bunch of s1,s100-s199 and format it to display, such as:God Demon: s106-109,s123,s125Imperial Sword: s106-109,s123,s125
Copy Code code as follows:
#!/usr/bin/env
Use Python to write some network services, when the network situation is not good, or resources occupy too much, the task congestion situation, always throw some exceptions, the current task is terminated, can be a good use of the @ Adorner, write a
The following starts to construct the HTTP packet,
The IP layer and the TCP layer use the Python impacket Library, and the HTTP content is filled out by itself.
Copy Code code as follows:
#!/usr/bin/env python
#----------------------
Objects in object (OOP) are a very important point of knowledge that we can simply think of as data and a collection of methods for accessing and manipulating the data. After learning a function, we know that if you reuse code, why use a class
Simple realization of the point k mean of the plane, using Euclidean distance, and Pylab display.
Copy Code code as follows:
Import Pylab as Pl
#calc Euclid SquireDef Calc_e_squire (A, B):Return (a[0]-b[0]) * * 2 + (a[1]-b[1) **2
#
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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service