Copy CodeThe code is as follows:
#-*-Coding:utf-8-*-
def insertion_sort (A):"" Insert sort, sub sort as bucket sort "" "n = Len (A)If n Return AB = [] # result ListFor a in a:i = Len (B)While I > 0 and B[i-1] > A:i = I-1B.insert (i, a);Return
Write scripts with Python for some time, often operate the database (MySQL), now to organize the operation of various types of databases, such as the following new parameters will be added, and gradually improve.
One,python operation MySQL: Details
Self-packaged coding class, under Windows recommended coding Rabbit (call the official DLL), Linux recommended Superman code (HTTP API)
Copy the Code code as follows:
# Coding:utf-8
From ctypes Import *
Import requests
Import JSON
Import
To install the Cookie,http server on the user's browser, add an HTTP header that resembles the following to the HTTP response:
Copy the Code code as follows:
set-cookie:session=8345234;expires=sun,15-nov-2013 15:00:00
See the Internet also has open source code, this does not, I took to carry on two times rewrite, hehe, on the code:
Copy the Code code as follows:
#encoding: Utf-8
Import socket
From Hashlib Import SHA1
From random import Randint
From struct import
Simple realization of the point K-mean analysis of the plane, using Euclidean distance, and Pylab display.
Copy the 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])
How does Redis work with Python? The following is an example of using Python to read and write Redis databases.
For example, we insert a piece of data, as follows:
Copy CodeThe code is as follows:
Import Redis
Class Database:
def __init__
1. Get file-hidden properties from the Windows attrib command
Copy CodeThe code is as follows:
Syntax
ATTRIB [+ Attribute |-attribute] [pathname] [/S [/d]]
Key+: Turn an attribute on-: Clear an attribute OFF
Pathname:drive and/or filename e.g. c:\*
preparatory work
Development environment: Python2.6,reportlab
Prepare the Chinese font file: SIMSUN.TTC
Code:
Copy the Code code as follows:
#!/usr/bin/env python2.6
#coding: Utf-8
Import Traceback
From reportlab.graphics.shapes import DrawingFrom
In the previous section from the zero-learning Python series of data Processing programming example (a) based on the change in the document, in addition to the student's results, the new student name and date of birth information, and therefore will
Encapsulation is the process of converting a Python data object into a stream of bytes, and unpacking is the inverse of the package, converting bytes in a byte file or byte object into a Python data object, and not unpacking the data from the
Many scenarios require an asynchronous callback mechanism for non-blocking. This is a simple example, please refer to the use of it
Copy CodeThe code is as follows:
#!/usr/bin/env python
#-*-Coding:utf-8-*-
Import logging
Import queue
Import
Code dependency: Networkx matplotlib
Copy the Code code as follows:
#! /bin/env python
#-*-Coding:utf-8-*-
Import Urllib
Import Urllib2
Import Cookielib
Import re
Import Cpickle as P
Import Networkx as NX
Import Matplotlib.pyplot as Plt
__author__
Python2.7 writes the specified element in the HTML and generates the Excle file
Copy the Code code as follows:
#coding =GBK
Import string
Import Codecs
Import Os,time
Import XLWT
Import xlrd
From BS4 import BeautifulSoup
From XLRD import
Although I have encountered this problem in Python, it is easier to explain it in Ruby. In Ruby, there are many ways to traverse an array, the two most common are for and each:
Copy CodeThe code is as follows:
arr = [' A ', ' B ', ' C ']
Arr.each
1.DNS query process:
Take query www.baidu.com as an example
(1) The computer sends a request to the local domain name server to resolve the www.baidu.com(2) After the local domain name server receives the request, queries the local cache first, if
1. Set up socket
Establishing a socket object requires knowing the type of communication and the Protocol family. The type of communication indicates what protocol is used to transfer the data. Examples of agreements include IPv4, IPV6, ipx\spx,
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