P

Python 数据结构与算法(en) 文档

Data Structures and Algorithms with Object-Oriented Design Patterns in Python。This book presents material identified in the Computing Curricula 1991 report of the ACM/IEEE-CS Joint Curriculum Task Force[47]. The book specifically addresses the following knowledge units: AL1: Basic Data structures, AL2: Abstract Data Types, AL3: Recursive Algorithms, AL4: Complexity Analysis, AL6: Sorting and Searching, and AL8: Problem-Solving Strategies. The breadth and depth of coverage is typical of what should appear in the second or third year of an undergraduate program in computer science/computer engineering.

mx234 2015-08-26   3345   0
P

Python 参考手册 文档

Python是一种解释性的,面向对象的,具有动态语义的高级程序设计语言。它内建高级数据结构,配以动态类型和动态捆绑,使其在快速应用开发中非常有利,就像脚本或粘合语言一样将已存在的构件连接在一起。Python的简单性和句法的易学性使其代码具有优秀的可读牲,因此维护程序的成本得以大大降低。Python具有模块和包的概念,以支持程序的模块化和代码重用。在主流平台上, Python的解释器和大量标准库都可以免费地以源代码形式或可执行文件形式获得,并且可以自由发布。

withinwind 2013-07-15   342   0

Python将byte数组转换为int 代码段

代码 import struct import ctypes def test_struct(buf, offset): return struct.unpack_from("I", buf, offset)[0] def test_ctypes(buf, offset): return ctypes.c_uint32.from_buffer(buf, offset).value def test

nc6433 2014-12-30   6958   0

python 实现各种排序算法 代码段

去掉添加到最终的结果集中,直到两个子序列归并完成。 代码如下: #!/usr/bin/python import sys def merge(nums, first, middle, last):

wcwx 2015-01-03   2524   0

bottle---Python的轻量级http server 代码段

相比于Django而言,bottle显得非常轻量级。短短几行代码即可快速搭建一个简易的http server。提供了 Python Web开发中需要的基本支持:URL路由,Request/Response对象封装,模板支持,

n24d 2015-01-04   8266   0
Python  

Python 验证码识别 代码段

Python识别验证码 #encoding=utf-8 import Image,ImageEnhance,ImageFilter import sys image_name = "./1.jpeg"

jopen 2015-01-10   1910   0

python 调用windows api查看系统的电量 代码段

通过调用GetSystemPowerStatus Windows Api来判断AC Power是开启还是关闭状态。是一个python调用windows api的例子。 import os import win32con import

phpopen 2015-01-09   6957   0
Python  

python连接sql server数据库 代码段

http://pymssql.sourceforge.net/ 下载pymssql模块,必须安装这个模块才可以用python连接mysql 以下是简单的访问代码,需要注意字符集 # -*- coding:gbk -*-

pythopen 2015-01-17   3255   0

python下载大文件代码 代码段

如果下载小文件,可以直接使用urllib.urlretrieve方法: import urllib urllib.urlretrieve ("http://www.example.com/songs/mp3.mp3", "mp3.mp3") 但是如果下载的文件尺寸很大,就不适合直接urlretrieve了。我们需要按块读取文件来下载: import urllib2 url = "http://do

pythopen 2015-01-17   3598   0
Python  

python连接mysql查询数据示例 代码段

使用 MySQLdb 模块连接 MySQL # coding=utf-8 #引入mysql python客户端模块 import MySQLdb import sys #进行数据库连接 conn = MySQLdb

dfee 2015-01-18   4689   0
Python  

python调用grep返回结果 代码段

下面的函数封装了系统的grep功能,传递文件名和参数返回grep的结果 import subprocess def grep(filename, arg): process = subprocess.Popen(['grep', '-n', arg, filename], stdout=subprocess.PIPE) stdout, stderr = process.communicate()

pkiek23 2015-01-18   2232   0
Python  

python自动裁剪图像 代码段

本代码可以帮你自动剪切掉图片的边缘空白区域,如果你的图片有大片空白区域(只要是同一颜色形成一定的面积就认为是空白区域),下面的python代码可以帮你自动切除,如果是透明图像,会自动剪切大片的透明部分。 本代码需要PIL模块 import

b573 2015-01-24   2554   0
Python  

python中的字典用法示例 代码段

/usr/bin/env python # # [SNIPPET_NAME: Dictionaries 101] # [SNIPPET_CATEGORIES: Python Core] # [SNIPPET_DESCRIPTION:

b573 2015-01-24   6220   0
Python  

python常用工具代码 代码段

parseFile(open("sample.xml")) parser.close() 7.python的GUI模块标准的是Tkinter,也有QT和MFC的模块,有兴趣的大家自己搜索下 import

m2yy 2015-02-01   3069   0
Python  

python实现的Caesar加解密算法 代码段

Caesar算法是最简单的加解密算法... # Caeser Cipher import sys,os MyCypher = 25 MyDict = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz `1234567890-=~!@#$%^&*()_+[]\\;\',./{}|:"<>?' plaintext = 'Hello World!

me87re 2015-05-04   1819   0
Python   算法  

python通过openpyxl生成Excel文件 代码段

使用前请先安装openpyxl: easy_install openpyxl 通过这个模块可以很方便的导出数据到Excel from openpyxl.workbook import Workbook from openpyxl.writer.excel import ExcelWriter from openpyxl.cell import get_column_letter from open

byyc 2015-05-27   1572   0
Python  

Python实现各种排序算法 代码段

1.冒泡排序 比较相邻的元素大小,将小的前移,大的后移,就像水中的气泡一样,最小的元素经过几次移动,会最终浮到水面上。 def bubble(list): for i in range(len(list)): for j in range(0,len(list)-1-i): if list[j] > list[j+1]: list[j],list[j+1]=list[j+1],list[j] if

jopen 2015-06-18   3456   2

Python 实现的"冒泡排序" 代码段

''''' Bubble Sort @author: aihua.sun ''' import string import random number = []; count = 0; def bubbleSort(): #initializeNumberArray(); generateRandomNumberArray(10, 1, 300); showArray(); sort(); sho

javap 2015-06-25   805   0
Python  

Python模拟http get 代码段

import sys, urllib2, urllib def addGETdata(url, data): '''Adds data to url. Data should be a list or tuple consisting of 2-item lists or tuples of the form: (key, value). Items that have no key should

nf83 2015-08-26   829   0
Python  

python获得本机机器名 代码段

import sys, socket hostname = socket.gethostname() # Try to get the fully-qualified name. print 'Fully-qualified name:', socket.getfqdn(hostname)

nf83 2015-08-26   741   0
Python  
1 2 3 4 5 6 7 8 9 10