Python algorithm learning bucket Sorting algorithm example (block sort)

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

Local file upload to seven Cow Cloud Server example (seven Qiniu storage)

Copy CodeThe code is as follows: # _*_ Coding:utf-8 _*_ #--------------------------------------- # program: Upload local files to seven Cow cloud server # Version: 0.1 # Author: Liu Jia # Date: 2014-01-07 # language: Python 2.7 #--------------------

Python connects MySQL, MongoDB, Redis, Memcache and other database methods

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

The use of coding rabbit and Superman to play the Code of self-styled to share the code class

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

Python deals with cookie explanations

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

Python development examples share BT seed crawler and seed parsing

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

Python implements a K-mean algorithm example (K-mean clustering algorithm)

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])

Python FTP operation class code sharing

Copy CodeThe code is as follows: #!/usr/bin/py2 #-*-Coding:utf-8-*- #encoding =utf-8 '''''FTP automatic download, automatic upload script, can be recursive directory operation''' From Ftplib import FTPImport OS, sys, string, datetime, TimeImport

Python read-write Redis database operation example

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__

Python methods for judging windows hidden files

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:\*

Python using Reportlab illustration example (Chinese characters included)

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

Example of data processing programming from the zero-learning Python series (II.)

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

A brief talk on the zero-learning Python series Methods of pickle module encapsulation and unpacking data Objects

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

Python Asynchronous Task Queue example

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

Use Python to draw the Renren friend diagram example

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__

Python calculates distances based on latitude and longitude examples

cos

Copy the Code code as follows: /*** Calculate distance between two points* @param _lat1-start Latitude* @param _lon1-start Longitude* @param _lat2-end Latitude* @param _lon2-end Longitude* @return km (rounded)*/public static double Getdistance

Python reads the specified element in HTML to generate the Excle file example

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

Each loop reference variable problem in Python and Ruby (a secret bug?)

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

Python implements DNS forward query, reverse query example

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

Python Network Programming Learning Note (ii): Socket set up network client

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,

Total Pages: 4013 1 .... 1913 1914 1915 1916 1917 .... 4013 Go to: GO

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.