1 For example python advocates a simple and practical idea, it does not have a switch statement, if you want to implement the effect of the switch statement
There are 2 ways to write
(1) using the IF Elif statement to implement
If
Copy Code code as follows:
Import Random
print ' N must >k else error '
N=int (Raw_input ("n="))
K=int (Raw_input ("k="))
Result=[]
X=range (N)
For I in range (k):
T=random.randint (i,n-1)
Temp=x[i]
X[I]=X[T]
X[t]=temp
Result.append (
Do you really want me to crack one? Forget it, just try my python level.
Python version
Copy Code code as follows:
#coding: GBK
Import Httplib, Urllib
def Check (username, password):
params = Urllib.urlencode (
{' UserID '
The following is written in Python, using lxml to do HTML analysis, from the Internet to see, that is the fastest analysis of Oh, but did not verify. Okay, on the code.
Copy Code code as follows:
Import Urllib
Import Urllib2
Import
opts, args = Getopt.getopt (sys.argv[1:], "t:s:h", ["walletype=", "servicename=", ' help '])
For A,o in opts:
If a in ('-t ', '--walletype '):
Walle_type = O
Elif A in (' s ', '--servicename '):
service_name = O
Elif A In ('-H ', '--help '):
Help =
1. Meta Character: . It matches any character except the newline character in the alternate mode (re. Dotall) It can even match line wrapping^ matches the beginning of the line. Unless you set the MULTILINE flag, it simply matches the start of the
1.match () Start match from start position2.search () Any position matching, if there are multiple matches, only return the first3.finditer () returns all matches4. Each match is the maximum match possible. For example:>>> m = re.compile (' abc[bcd]*
Theory does not say much:
Copy Code code as follows:
#!/usr/bin/python
Import Sys
def merge (array, q, p, r):
Left_array = array[q:p+1]
Right_array = array[p+1:r+1]
Left_array_num = Len (left_array)
Right_array_num = Len
QUICKSORT (A, p, R) is a fast-sequencing subroutine that calls the partitioning program to partition the array, and then recursively calls QUICKSORT (A, p, R) to complete the quick sort process. The worst time complexity for fast sorting is O (N2),
The following is the final code (implemented under Windows)
Copy Code code as follows:
#-*-coding:cp936-*-
Import OS
Path = ' d:\\ picture \ \ '
For file in Os.listdir (path):
If Os.path.isfile (Os.path.join (path,file)) ==true:
If
Objective
Flow information can be directly in the /proc/net/dev view, the author implemented the program to use the command:
Python net.py interface
Which interface is the name of the network card, what network card to use, the
Basic definition of Duck type
First Python does not support polymorphism or polymorphism, Python is a polymorphic language advocating duck type.
The following is a discussion of the types of ducks in Wikipedia:
In programming, duck type (English:
Wrong code ①
D = {' A ': 1, ' B ': 0, ' C ': 1, ' d ': 0}
for key, Val in D.items ():
del (D[k])
Wrong code ②--for Python3
D = {' A ': 1, ' B ': 0, ' C ': 1, ' d ': 0}
for key, Val in D.keys ():
del (D[k])
The right Code
D
Recently another part of the site, as the site increased, management complexity also come up, as the saying goes: A lot of bad belt, I found that the site is not a good pipe, because these sites have important and unimportant, the site of the
Introduction to ioPS
IOPS is mainly used in data, this indicator is a database performance evaluation of an important reference, IOPS is the number of read/write (I/O) operations per second, mainly to see the performance of random access, generally
Objective
To define a function in Python, you can use required parameters, default parameters, variable parameters, and keyword parameters, all 4 of which can be used together, or only some of them, but note that the order in which the parameters
Implementation effect
From the source picture, in the current working directory in the/IMG directory to generate 1000 pieces, from 1*1 to 1000*1000 pixels of the picture.
The effect is as follows:
Directory structure
implementation example
When it comes to operational alarm, I think all can write a long history to explain the alarm in detail before the Shilai, such as the first alarm are used by mail, but the real-time message is not high, such as home from work can not always stare
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