[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/programthink/opensource/master/libs/python.wiki [Back]  [Original]

Python

= = = = Python Python / Python GitHub [https://github.com/programthink/opensource/issues issue][https://program-think.blogspot.com/ ] ---- = 1 = == 1.1 == === 1.1.1 ===

re

=== 1.1.2 ===

chardet

Home[https://github.com/erikrose/chardet] chardet chardet import chardet print(chardet.detect(bytes)) === 1.1.3 ===

StringIO & cStringIO

cStringIO C StringIO Python Unicode

difflib

diff s l l s == 1.2 & == === 1.2.1 base64 === [https://en.wikipedia.org/wiki/Base64 Base64]

base64

Base16Base32Base64 === 1.2.2 UUencode === [https://en.wikipedia.org/wiki/Uuencode UUencode] Unix

uu

UUencode === 1.2.3 BinHex === [https://en.wikipedia.org/wiki/BinHex BinHex] Mac OS UUencode

binhex

BinHex == 1.3 ==

math

......

random

0-100 import random random.seed() random.randint(0, 100)

fractions

== 1.4 ==

pygtrie

Home[https://github.com/google/pytrie] Google [https://zh.wikipedia.org/wiki/Trie trie]/ ---- = 2 = Python Python == 2.1 C & C++ ==

ctypes

ctypes Python 2.5 C/C++ Python C/C++ Linux/Unix C from ctypes import * libc = CDLL("libc.so.6") time = libc.time(None) Windows API from ctypes import c_int, WINFUNCTYPE, windll from ctypes.wintypes import HWND, LPCSTR, UINT prototype = WINFUNCTYPE(c_int, HWND, LPCSTR, LPCSTR, UINT) paramflags = (1, "hwnd", 0), (1, "text", "Hi"), (1, "caption", None), (1, "flags", 0) MessageBox = prototype(("MessageBoxA", windll.user32), paramflags) MessageBox(text="Hello, world", flags=2)

SWIGSimplified Wrapper and Interface Generator

Home[http://swig.org/] Links[https://en.wikipedia.org/wiki/SWIG Wikipedia] JavaPythonC#RubyPHPPerlLuaGo ... C/C++

Cython

Home[http://cython.org/] Python Python C/C++ == 2.2 JVM ==

Jython

Home[http://www.jython.org/] Links[https://en.wikipedia.org/wiki/Jython Wikipedia] [https://zh.wikipedia.org/wiki/Jython ] Jython Python JVM JVM JavaScala == 2.3 dotNet ==

IronPython

Home[http://ironpython.net/] Links[https://en.wikipedia.org/wiki/IronPython Wikipedia] [https://zh.wikipedia.org/wiki/IronPython ] IronPython Python dotNET dotNET C#F#VB.Net ... == 2.4 Go ==

gopy

Home[https://github.com/go-python/gopy] gopy Go Python module Python Go Python == 2.5 Objective-C ==

PyObjC

Home[http://pyobjc.sourceforge.net/] Python Mac OS X Objective-C ---- = 3 = == 3.1 ==

os

shutil

os shutil ... import shutil shutil.rmtree(xxxx)

glob

* ? txt import glob for file in glob.glob("./*.txt") : print(file)

fnmatch

glob txt import os, fnmatch for file in os.listdir(".") : if fnmatch.fnmatch(file, "*.txt") : print(file)

tempfile

== 3.2 ==

threading

API/ import threading import time def my_thread() : print("Thread started!") time.sleep(3) print("Thread finished!") threading.Thread(target=my_thread).start() import threading import time from __future__ import print_function class MyThread(threading.Thread) : def run(self) : print("{} started!".format(self.getName())) time.sleep(3) print("{} finished!".format(self.getName())) if __name__ == "__main__" : for n in range(10) : mythread = MyThread(name = "Thread-{}".format(n + 1)) mythread.start() time.sleep(1) == 3.3 ==

subprocess

import subprocess output = subprocess.check_output(["dir"]) # output = subprocess.check_output(["netstat", "-an"]) #

multiprocessing

2.6 API threading / Lock print from multiprocessing import Process, Lock def f(lock, n) : lock.acquire() print("hello world %d" % n) lock.release() if __name__ == "__main__" : lock = Lock() for num in range(10): Process(target=f, args=(lock, num)).start()

sh

Home[https://github.com/amoffat/sh] subprocess Python2 Python3 subprocess from sh import ifconfig print(ifconfig("wlan0")) from sh import curl # curl("https://program-think.blogspot.com/", "-o", "test.html", "--silent") # curl("https://program-think.blogspot.com/", o="test.html", silent=True) from sh import ls, wc print(wc(ls("/etc", "-1"), "-l")) == 3.4 IPC ==

mmap

mmap import os import mmap map = mmap.mmap(-1, 13) map.write("Hello, world") pid = os.fork() if pid == 0 : # map.seek(0) print(map.readline()) map.close()

signal

Linux & UNIX == 3.5 ==

keyboard

Home[https://github.com/boppreh/keyboard] hook python Windows Linux import keyboard # keyboard.press_and_release("shift+s, space") # keyboard.add_hotkey("page up, page down", lambda: keyboard.write("xxxx")) # keyboard.wait("esc") # ESC3 recorded = keyboard.record(until="esc") keyboard.play(recorded, speed_factor=3) == 3.6 ==

sys

sys.argv # List sys.exit(0) # 0 sys.version # Python

platform

import platform platform.platform() # "Windows-7-6.1.7601-SP1" platform.version() # "6.1.7601" platform.architecture() # ("32bit", "WindowsPE")

psutil

Home[https://github.com/giampaolo/psutil] psutilPython system and process utilitiesCPU import psutil psutil.cpu_count() # CPU psutil.cpu_freq() # CPU psutil.virtual_memory() # psutil.swap_memory() # psutil.disk_partitions() # psutil.disk_usage('/') # psutil.users() # p = psutil.Process(pid) # pid p.name() # p.exe() # p.cwd() # p.cmdline() # == 3.7 Linux & Unix ==

syslog

POSIX syslog == 3.8 Windows ==

PyWin32

Home[http://python.net/crew/mhammond/win32/] Windows API COM API Python Windows COM Windows == 3.9 ==

PyInstaller

Home[http://www.pyinstaller.org/] PyInstaller Python Python WindowsLinuxMac OS XSolarisAIX

py2exe

Home[http://www.py2exe.org/] Links[https://en.wikipedia.org/wiki/Py2exe Wikipedia] py2exe PyInstaller Windows

py2app

Home[https://bitbucket.org/ronaldoussoren/py2app] [http://www.py2exe.org/ py2exe] [http://www.py2exe.org/ py2exe] Windows [https://bitbucket.org/ronaldoussoren/py2app py2app] Mac OS X

EasyInstall & Setuptools

Home[https://pypi.python.org/pypi/setuptools] ---- = 4 Web = == 4.1 HTTP Client ==

httplib & httplib2 & http.request & urllib.parse

HTTP GETPOST Python2 httplib httplib2 Python3 http.request urllib.parse URL import urllib handle = urllib.urlopen("http://www.google.com") page = handle.read() handle.close()

Requests

Home[http://www.python-requests.org/] HTTP >>> r = requests.get('https://api.github.com/user', auth=('user', 'pass')) >>> r.status_code 200 >>> r.headers['content-type'] 'application/json; charset=utf8' >>> r.encoding 'utf-8' >>> r.text u'{"type":"User"...' >>> r.json() {u'private_gists': 419, u'total_private_repos': 77, ...} == 4.2 HTTP Server ==

SimpleHTTPServer & http.server

HTTP Server Python2 SimpleHTTPServer Python3 http.server HTTP import SocketServer import SimpleHTTPServer PORT = 8080 Handler = SimpleHTTPServer.SimpleHTTPRequestHandler httpd = SocketServer.TCPServer(("", PORT), Handler) print("serving at port %d" % PORT) httpd.serve_forever() == 4.3 Web == Python Web

Django

Home[https://www.djangoproject.com/] Links[https://en.wikipedia.org/wiki/Django_(web_framework) Wikipedia] [https://zh.wikipedia.org/wiki/Django ] Python Django Web Web ORM Django Google Web GAE Jython J2EE

TurboGears

Home[http://www.turbogears.org/] Links[https://en.wikipedia.org/wiki/TurboGears Wikipedia] [https://zh.wikipedia.org/wiki/TurboGears ] Web Django Django Full-Stack Frameworks

CherryPy

Home[http://www.cherrypy.org/] Links[https://en.wikipedia.org/wiki/CherryPy Wikipedia] Web Web TurboGears Hello world import cherrypy class HelloWorld(object) : def index(self) : return "Hello World!" index.exposed = True cherrypy.quickstart(HelloWorld())

web.py

Home[http://webpy.org/] DjangoTurboGearsIt's the anti-framework framework. [https://en.wikipedia.org/wiki/Aaron_Swartz Aaron Swartz][http://program-think.blogspot.nl/2013/01/weekly-share-37.html ] Aaron Swartz web.py [https://en.wikipedia.org/wiki/Reddit reddit] Web 2.0 Hello world import web urls = ( "/", "index" ) class index : def GET(self) : return "Hello, world!" if __name__ == "__main__" : app = web.application(urls, globals()) app.run()

Flask

Home[http://flask.pocoo.org/] Links[https://zh.wikipedia.org/wiki/Flask ] Web Werkzeug WSGI Jinja2 Hello world from flask import Flask app = Flask(__name__) app.route("/") def hello_world() : return Hello World!" if __name__ == "__main__" : app.run()

Tornado

Home[http://www.tornadoweb.org/] Links[https://zh.wikipedia.org/wiki/Tornado ] Web Web.py IO == 4.4 Web & JS ==

Pyjamas & pyjs

Home[http://pyjs.org/] GWTGoogle Web Toolkit Python JS AJAX Pyjamas GUI

pyjaco

Home[https://github.com/chrivers/pyjaco] Python JavaScript == 4.5 ==

webbrowser

URL Google import webbrowser webbrowser.open("http://www.google.com")

pyv8

Home[https://pypi.python.org/pypi/PyV8] [https://developers.google.com/v8/ v8] Google JavaScript v8 Python import PyV8 ctxt1 = PyV8.JSContext() ctxt1.enter() ctxt1.eval("1+2") # JS class Global(PyV8.JSClass) : # JS def hello(self) : print("Hello, world") ctxt2 = PyV8.JSContext(Global()) # JS Global ctxt2.enter() ctxt2.eval("hello()") # hello()

PyWebKitGtk

Home[https://github.com/jmalonzo/pywebkitgtk] [http://webkitgtk.org/ WebKitGtk] WebKit Web PyWebKitGtk WebKitGtk Python == 4.6 WebSocket == WebSocket [https://zh.wikipedia.org/wiki/WebSocket ]

pywebsocket

Home[https://github.com/google/pywebsocket] Google WebSocket server Apache mod_pywebsocket

AutobahnPython

Home[https://github.com/crossbario/autobahn-python] [http://crossbar.io/autobahn Autobahn] WebSocket & Python2 Python3 PyPy Jython asyncio [https://en.wikipedia.org/wiki/Twisted_%28software%29 Twisted] WebSocket WAMPWeb Application Messaging Protocol Echo Server from autobahn.twisted.websocket import WebSocketServerProtocol class MyServerProtocol(WebSocketServerProtocol) : def onConnect(self, request) : print("Client connecting: {}".format(request.peer)) def onOpen(self) : print("WebSocket connection open.") def onMessage(self, payload, isBinary) : if isBinary : print("Binary message received: {} bytes".format(len(payload))) else: print("Text message received: {}".format(payload.decode("utf8"))) self.sendMessage(payload, isBinary) def onClose(self, wasClean, code, reason) : print("WebSocket connection closed: {}".format(reason))

ws4py

Home[https://github.com/Lawouach/WebSocket-for-Python] WebSocket & Python2 Python3 CherryPygeventwsgirefasyncioTornadogevent == 4.7 ==

selenium

Home[http://www.seleniumhq.org/] selenium Web from selenium import webdriver driver = webdriver.Chrome() driver.get("http://192.168.1.1") driver.find_element_by_xpath('//*[@id="lgPwd"]').send_keys("123456") driver.find_element_by_xpath('//*[@id="loginSub"]').click() driver.quit()

scrapy

Home[https://scrapy.org/] Links[https://en.wikipedia.org/wiki/Scrapy Wikipedia] Scrapy ---- = 5 = == 5.1 & ==

Scapy

Home[http://www.secdev.org/projects/scapy/] Links[https://en.wikipedia.org/wiki/Scapy Wikipedia] Sniffer # ping ans,unans = sr(IP(dst="192.168.1.1-254")/ICMP()) # ARP ans,unans = srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst="192.168.1.0/24"), timeout=2) == 5.2 ==

socket

Python socket API BSD SOCKET

asyncore

SOCKET

asynchat

asyncore API == 5.3 == === 5.3.1 ===

PycURL

Home[http://pycurl.sourceforge.net/] [https://en.wikipedia.org/wiki/Curl cURL] / N [https://program-think.blogspot.com/2009/03/opensource-review-curl-library.html ] PycURL cURL Python HTTP GET import pycurl try : from io import BytesIO except ImportError : from StringIO import StringIO as BytesIO buffer = BytesIO() curl = pycurl.Curl() curl.setopt(curl.URL, "http://pycurl.sourceforge.net/") curl.setopt(curl.WRITEDATA, buffer) curl.perform() curl.close() body = buffer.getvalue() === 5.3.2 HTTP === HTTP Web === 5.3.3 ===

ftplib

FTPFile Transfer Protocol FTP from ftplib import FTP ftp = FTP("ftp.debian.org") # 21 ftp.login() # ftp.cwd("debian") # "debian" ftp.retrlines("LIST") # ftp.quit()

pysftp

Home[https://bitbucket.org/dundeemt/pysftp] [https://en.wikipedia.org/wiki/SSH_File_Transfer_Protocol SFTP] ssh.py / import pysftp with pysftp.Connection("hostxxx", username="userxxx", password="xxxxxx") as sftp : with sftp.cd("public") # public sftp.put("/my/local/filename") # public sftp.get_r("myfiles", "/local") # === 5.3.4 ===

smtplib

SMTPSimple Mail Transfer Protocol

imaplib

IMAPInternet Message Access Protocol

poplib

POP3Post Office Protocol v3

yagmail

Home[https://github.com/kootenpv/yagmail] import yagmail yag = yagmail.SMTP("my_gmail_username", "my_gmail_password") contents = ["This is the body, and here is just text http://somedomain/image.png", "You can find an audio file attached.', '/local/path/song.mp3"] yag.send("to@someone.com", "subject", contents) === 5.3.5 ===

jabber.py

Home[http://jabberpy.sourceforge.net/] Jabber XMPPIM Python

irclib

Home[https://bitbucket.org/jaraco/irc] IRC Internet Relay Chat Python

pyTelegramBotAPI

Home[https://github.com/eternnoir/pyTelegramBotAPI] [https://core.telegram.org/bots TelegramBot]

Telethon

Home[https://github.com/LonamiWebs/Telethon] Python3 [https://telegram.org/ Telegram] === 5.3.6 ===

telnetlib

telnet telnet import telnetlib import getpass host = raw_input("Enter remote host: ") user = raw_input("Enter your remote account: ") password = getpass.getpass() tn = telnetlib.Telnet(host) tn.read_until("login: ") tn.write(user + "\n") if password : tn.read_until("Password: ") tn.write(password + "\n") tn.write("ls\n") tn.write("exit\n") print tn.read_all()

rdpy

Home[https://github.com/citronneur/rdpy] Python RDP[https://en.wikipedia.org/wiki/Remote_Desktop_Protocol ] VNC[https://en.wikipedia.org/wiki/Virtual_Network_Computing Virtual Network Computing] Twisted

paramiko

Home[http://www.paramiko.org/] paramiko python SSH2 SSH paramiko SFTP import paramiko ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect("IP", port, "username", "password") === 5.3.7 ===

urlparse

URL Python 2.5 Python 2.7 IPv6 URL == 5.4 ==

Protocol Buffers

Home[https://developers.google.com/protocol-buffers/] Links[https://en.wikipedia.org/wiki/Protocol_Buffers Wikipedia] Google / protobuf[https://program-think.blogspot.com/2009/05/opensource-review-protocol-buffers.html ] Protocol Buffers Google C++JavaPython

Apache Thrift

Home[https://thrift.apache.org/] Links[https://en.wikipedia.org/wiki/Apache_Thrift Wikipedia] Apache Thrift Thrift Google Protocol Buffers == 5.5 ==

Twisted

Home[http://twistedmatrix.com/] Links[https://en.wikipedia.org/wiki/Twisted_%28software%29 Wikipedia] Python 2002 C++ [https://en.wikipedia.org/wiki/Adaptive_Communication_Environment ACE] TCP UDPHTTPXMPPSSHIRC ... Echo 12345 from twisted.internet import protocol, reactor class Echo(protocol.Protocol) : def dataReceived(self, data) : self.transport.write(data) class EchoFactory(protocol.Factory) : def buildProtocol(self, addr) : return Echo() reactor.listenTCP(12345, EchoFactory()) reactor.run()

gevent

Home[http://www.gevent.org/] [https://zh.wikipedia.org/wiki/%E5%8D%8F%E7%A8%8B ] libevent libev gevent [https://github.com/gevent/gevent/wiki/Projects gevent wiki] from gevent import socket import gevent hosts = ["google.com", "github.com", "program-think.blogspot.com"] jobs = [gevent.spawn(socket.gethostbyname, host) for host in hosts] gevent.joinall(jobs, timeout=2) print([job.value for job in jobs])

PyZMQ

Home[https://github.com/zeromq/pyzmq] ZMQZeroMQ Python Python2 Python3 PyZMQ 2.2 ZMQ 3.x 4.x

nanomsg-python

Home[https://github.com/tonysimpson/nanomsg-python] nanomsg Python Python2 Python3 Hello world from __future__ import print_function from nanomsg import Socket, PAIR, PUB s1 = Socket(PAIR) s2 = Socket(PAIR) s1.bind("inproc://test") s2.connect("inproc://test") s1.send(b"hello world") print(s2.recv()) s1.close() s2.close() == 5.6 ==

Apache Libcloud

Home[https://libcloud.apache.org/] API DNS from libcloud.dns.types import Provider, RecordType from libcloud.dns.providers import get_driver cls = get_driver(Provider.ZERIGO) driver = cls("email", "api key") zones = driver.list_zones() zone = [zone for zone in zones if zone.domain == "mydomain.com"][0] record = zone.create_record(name="www", type=RecordType.A, data="127.0.0.1") print(record) ---- = 6 = Python API [https://www.python.org/dev/peps/pep-0249/ PEP 249] == 6.1 == === 6.1.1 ODBC ===

pyODBC

Home[https://github.com/mkleehammer/pyodbc] pyODBC ODBC API ODBC ODBC import pyodbc conn = pyodbc.connect("DSN=xxx;PWD=password") cursor = conn.cursor() cursor.execute("SELECT field1 FROM table1") while True : row = cursor.fetchone() if not row : break print(row) cursor.close() conn.close()

ceODBC

Home[http://ceodbc.sourceforge.net/] ODBC API === 6.1.2 JDBC ===

Jython

Jython [https://en.wikipedia.org/wiki/Jdbc JDBC] === 6.1.3 ADO & ADO.NET ===

PyWin32

PyWin32 [https://en.wikipedia.org/wiki/ActiveX_Data_Objects ADO]

IronPython

IronPython [https://en.wikipedia.org/wiki/ADO.NET ADO.NET] == 6.2 == === 6.2.1 MySQL ===

MySQL for Python

Home[http://mysql-python.sourceforge.net/] MySQL MySQL import MySQLdb conn = MySQLdb.connect(db="test", passwd="password") cursor = conn.cursor() cursor.execute("SELECT field1 FROM table1") while True : row = cursor.fetchone() if not row : break print(row) cursor.close() conn.close() === 6.2.2 PostgreSQL ===

psycopg

Home[http://initd.org/psycopg/] PostgreSQL

PyGreSQL

Home[http://www.pygresql.org/] PostgreSQL === 6.2.3 Oracle ===

cx_Oracle

Home[http://cx-oracle.sourceforge.net/] Oracle === 6.2.4 MS SQL Server ===

pymssql

Home[http://pymssql.org/] SQL Server === 6.2.5 IBM DB2 ===

ibm-db

Home[https://pypi.python.org/pypi/ibm_db] DB2 === 6.2.6 SQLite ===

sqlite3

sqlite3 Python 2.5 SQLite [https://en.wikipedia.org/wiki/SQLite SQLite] [https://program-think.blogspot.com/2009/04/how-to-use-sqlite.html ] import sqlite3 conn = sqlite3.connect(":memory:") # ":memory:" cursor = conn.cursor() cursor.execute("CREATE TABLE person (name text, age int)") cursor.execute("INSERT INTO stocks VALUES ('TOM',20)") conn.commit() conn.close() === 6.2.7 MongoDB ===

PyMongo

Docs[https://docs.mongodb.com/ecosystem/drivers/python/] MongoDB Python === 6.2.8 Apache HBase ===

HappyBase

Home[https://github.com/wbolster/happybase] HBase Python [https://en.wikipedia.org/wiki/Apache_Thrift Thrift] HBase import happybase connection = happybase.Connection("hostname") table = connection.table("table-name") table.put(b"row-key", {b"test1": b"data1", b"test2": b"data2"}) row = table.row(b"row-key") print(row[b"test1"]) === 6.2.9 Redis ===

redis-py

Home[https://github.com/andymccurdy/redis-py] Redis Python import redis r = redis.StrictRedis(host="localhost", port=6379, db=0) r.set("foo", "bar") print(r.get("foo")) === 6.2.10 LevelDB ===

Plyvel

Home[https://github.com/wbolster/plyvel] LevelDB Python Python2 Python3 import plyvel db = plyvel.DB("/tmp/testdb/", create_if_missing=True) db.put(b"key", b"value") print(db.get(b"key")) db.close() === 6.2.11 Berkeley DB ===

PyBSDDB

Home[http://www.jcea.es/programacion/pybsddb.htm] Berkeley DB == 6.3 ORMObject-Relational Mapping ==

SQLAlchemy

Home[http://www.sqlalchemy.org/] Links[https://en.wikipedia.org/wiki/SQLAlchemy Wikipedia] [https://zh.wikipedia.org/wiki/SQLAlchemy ] SQLAlchemy MySQLPostgreSQLSqliteOracleMS SQL ServerFirebirdSybase SQL ServerInformix from sqlalchemy import * from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import relation, sessionmaker Base = declarative_base() class Movie(Base) : __tablename__ = "movies" id = Column(Integer, primary_key=True) title = Column(String(255), nullable=False) year = Column(Integer) directed_by = Column(Integer, ForeignKey("directors.id")) director = relation("Director", backref="movies", lazy=False) def __init__(self, title=None, year=None) : self.title = title self.year = year def __repr__(self) : return "Movie(%r, %r, %r)" % (self.title, self.year, self.director) class Director(Base) : __tablename__ = "directors" id = Column(Integer, primary_key=True) name = Column(String(50), nullable=False, unique=True) def __init__(self, name=None) : self.name = name def __repr__(self) : return "Director(%r)" % (self.name) Base.metadata.create_all(create_engine("dbms://user:pwd@host/dbname"))

SQLObject

Home[http://sqlobject.org/] Links[https://en.wikipedia.org/wiki/SQLObject Wikipedia] SQLObject MySQLPostgreSQLSqliteMS SQL ServerFirebirdSybase SQL ServerSAP DB from sqlobject import * sqlhub.processConnection = connectionForURI("sqlite:/:memory:") class Person(SQLObject) : first_name = StringCol() last_name = StringCol() Person.createTable()

Peewee

Home[http://www.peewee-orm.com/] ORM SQLiteMySQL PostgreSQL Python2 Python3 from peewee import * db = SqliteDatabase("test.db") class Person(Model) : name = CharField() birthday = DateField() is_relative = BooleanField() class Meta : database = db # This model uses the "test.db". class Pet(Model) : owner = ForeignKeyField(Person, related_name="pets") name = CharField() animal_type = CharField() class Meta : database = db # This model uses the "test.db". db.connect() db.create_tables([Person, Pet]) ---- = 7 GUI = == 7.1 GUI == === 7.1.1 Tk === [https://en.wikipedia.org/wiki/Tk_(framework) Tk]

Tkinter & tkinter

Python Tcl/Tk Python2 Tkinter Python3 tkinter Tkinter Hello world from Tkinter import * if __name__ == "__main__" : root = Tk() label = Label(root, text="Hello, world") label.pack() root.mainloop() === 7.1.2 wxWidgets === [https://en.wikipedia.org/wiki/WxWidgets wxWidgets] C++ GUI

wxPython

Home[http://www.wxpython.org/] Links[https://en.wikipedia.org/wiki/WxPython Wikipedia] [https://zh.wikipedia.org/wiki/WxPython ] wxWidgets Python [https://github.com/limodou/ulipad Ulipad] Python IDE wxPython wxPython Hello world import wx class Frame(wx.Frame) : pass class App(wx.App) : def OnInit(self) : self.frame = Frame(parent=None, title="Hello, world") self.frame.Show() self.SetTopWindow(self.frame) return True if __name__ == "__main__" : app = App() app.MainLoop()

PythonCard

Home[http://pythoncard.sourceforge.net/] wxWidgets GUI === 7.1.3 GTK+ === [https://en.wikipedia.org/wiki/GTK%2B GTK+] GIMP Toolkit C

PyGTK

Home[http://www.pygtk.org/] Links[https://en.wikipedia.org/wiki/PyGTK Wikipedia] Python GTK+2 PyGTK Hello world import pygtk pygtk.require("2.0") import gtk class HelloWorld : def __init__(self) : self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.connect("delete_event", self.delete_event) self.window.connect("destroy", self.destroy) self.window.set_border_width(10) self.button = gtk.Button("Hello, world") self.button.connect("clicked", self.hello, None) self.button.connect_object("clicked", gtk.Widget.destroy, self.window) self.window.add(self.button) self.button.show() self.window.show() def main(self) : gtk.main() def hello(self, widget, data=None) : print("Hello, world") def delete_event(self, widget, event, data=None) : print("delete event occurred") return False def destroy(self, widget, data=None) : gtk.main_quit() if __name__ == "__main__" : hello = HelloWorld() hello.main()

PyGObjectPyGI

Home[https://live.gnome.org/PyGObject] Python GTK+3 PyGTK PyGObject Hello world from gi.repository import Gtk class MyWindow(Gtk.Window): def __init__(self): Gtk.Window.__init__(self, title="Hello World") self.button = Gtk.Button(label="Click Here") self.button.connect("clicked", self.on_button_clicked) self.add(self.button) def on_button_clicked(self, widget): print("Hello, world!") win = MyWindow() win.connect("delete-event", Gtk.main_quit) win.show_all() Gtk.main() === 7.1.4 Qt === [https://en.wikipedia.org/wiki/Qt_(toolkit) Qt] C++ GUI

PyQt

Home[http://www.riverbankcomputing.com/software/pyqt/] Links[https://en.wikipedia.org/wiki/PyQt Wikipedia] [https://zh.wikipedia.org/wiki/PyQt ] Python Qt pyQt Hello world import sys from PyQt4.QtGui import * if __name__ == "__main__" : app = QApplication(sys.argv) window = QWidget() window.resize(320, 240) window.setWindowTitle("Hello, world") window.show() sys.exit(app.exec_())

PySide

Home[http://www.pyside.org/] Python Qt === 7.1.5 FLTK === [https://en.wikipedia.org/wiki/FLTK FLTK] Fast Light Tool Kit C++

PyFLTK

Home[http://pyfltk.sourceforge.net/] Python FLTK === 7.1.6 Windows ===

PyWin32

PyWin32 Windows GUI

IronPython

IronPython dotNET GUI === 7.1.7 JVM ===

Jython

Jython Java [https://en.wikipedia.org/wiki/Swing_%28Java%29 Swing] === 7.1.8 ===

EasyGUI

Home[http://easygui.sourceforge.net/] EasyGUI GUI

PyGUI

Home[http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/] PyGUI GUI [http://python.net/crew/mhammond/win32/ PyWin32]Windows [http://www.pygtk.org/ PyGTK]Linux [http://pyobjc.sourceforge.net/ PyObjC]Mac OS X

Kivy

Home[http://kivy.org/] Android / iOS

OcempGUI

Home[http://ocemp.sourceforge.net/gui.html] PyGame GUI PyGame == 7.2 & ==

matplotlib

Home[http://matplotlib.org/] Links[https://en.wikipedia.org/wiki/Matplotlib Wikipedia] [http://www.scipy.org/ SciPy] MATLAB [http://matplotlib.org/users/screenshots.html ]

Gnuplot.py

Home[http://gnuplot-py.sourceforge.net/] Python [http://www.gnuplot.info/ gnuplot] gnuplot [http://www.gnuplot.info/screenshots/index.html ]

PyQtGraph

Home[http://www.pyqtgraph.org/] Python PyQt4 / PySide[http://www.pyqtgraph.org/images/plotting_sm.png ]

PyX

Home[http://pyx.sourceforge.net/] TeX / LaTeX PostScript / PDF [http://pyx.sourceforge.net/gallery/index.html ]

Chaco

Home[http://code.enthought.com/chaco/] 2[http://docs.enthought.com/chaco/user_manual/annotated_examples.html ]

Plotly

Home[https://plot.ly/] plotly PythonRMATLABExcelJavaScriptjupyter ---- = 8 = == 8.1 ==

hashlib

Python 2.5 MD5 SHA1 SHA224 SHA256 SHA384 SHA512 [https://program-think.blogspot.com/2013/02/file-integrity-check.html ] SHA1 import hashlib sha1 = hashlib.sha1("Hello, world").hexdigest()

PyCrypto

Home[http://www.dlitz.net/software/pycrypto/] DESAESIDEA RSADSA MD5SHA1RIPEMD

pyOpenSSL

Home[http://pyopenssl.sourceforge.net/] [https://en.wikipedia.org/wiki/OpenSSL OpenSSL] Python OpenSSL

Keyczar

Home[https://github.com/google/keyczar] Google C++JavaPython API

passlib

Home[https://bitbucket.org/ecollins/passlib/] passlib >>> # import the hash algorithm >>> from passlib.hash import pbkdf2_sha256 >>> # generate new salt, and hash a password >>> hash = pbkdf2_sha256.hash("toomanysecrets") >>> hash '$pbkdf2-sha256$29000$N2YMIWQsBWBMae09x1jrPQ$1t8iyB2A.WF/Z5JZv.lfCIhXXN33N23OSgQYThBYRfk' >>> # verifying the password >>> pbkdf2_sha256.verify("toomanysecrets", hash) True >>> pbkdf2_sha256.verify("joshua", hash) False == 8.2 ==

oauth2client

Home[https://github.com/google/oauth2client] Google OAuth OAuth 2.0 ---- = 9 = == 9.1 == === 9.1.1 CSV === [https://en.wikipedia.org/wiki/Comma-separated_values CSV]

csv

CSV === 9.1.2 JSON === JSON JavaScript Web

json

JSON / JSON import json json.dumps(["foo", {"bar": ("baz", None, 1.0, 2)}]) # JSON # # """["foo", {"bar": ["baz", null, 1.0, 2]}]""" json.loads("""["foo", {"bar":["baz", null, 1.0, 2]}]""") # JSON # # [u"foo", {u"bar": [u"baz", None, 1.0, 2]}] === 9.1.3 YAML === [https://en.wikipedia.org/wiki/YAML YAML] json json

PyYAML

Home[http://pyyaml.org/] pyyaml Python YAML == 9.2 & == === 9.2.1 zip ===

zipfile

zip === 9.2.2 bzip2bz2 ===

bz2

bzip2 === 9.2.3 gzipgz ===

gzip

gzip

zlib

zlib === 9.2.4 tar ===

tarfile

tar === 9.2.5 7zip7z ===

PyLZMA

Home[http://www.joachim-bauch.de/projects/pylzma/] 7zip === 9.2.6 rar ===

rarfile

Home[http://rarfile.berlios.de/] rar === 9.2.7 msi ===

msilib

msi Python 2.5 == 9.3 == === 9.3.1 XML ===

xml.dom & xml.miniDom & xml.etree.ElementTree

DOMDocument Object Model XML

xml.sax & xml.parsers.expat

SAXSimple API for XML XML

lxml

Home[http://lxml.de/] C libxml libxslt Python XPath 1.0XSLT 1.0 EXSLT HTML === 9.3.2 HTML ===

HTMLParser

HTML/XHTML

beautifulsoup

Home[https://www.crummy.com/software/BeautifulSoup/] Links[https://zh.wikipedia.org/zh-cn/Beautiful_Soup ] Beautiful Soup HTML XML requests selenium == 9.4 PDF ==

pyfpdf

Home[https://github.com/reingart/pyfpdf] [http://www.fpdf.org/ FPDF] Python PDF Hello World from fpdf import FPDF pdf = FPDF() pdf.add_page() pdf.set_font("Arial", "B", 16) pdf.cell(40, 10, "Hello, World") pdf.output("test.pdf", "F") HTML HTML tag from pyfpdf import FPDF, HTMLMixin class MyFPDF(FPDF, HTMLMixin) : pass pdf = MyFPDF() pdf.add_page() pdf.write_html(html) pdf.output("test.pdf", "F")

pyPdf & PyPDF2

Home[http://knowah.github.com/PyPDF2/] pyPdf PyPDF2 pyPdf //

PDFMiner

Home[http://www.unixuser.org/~euske/python/pdfminer/] PDF HTML == 9.5 MS Office == === 9.5.1 Worddocdocx ===

python-docx

Home[https://github.com/python-openxml/python-docx] python docx docx Python2 Python3

PyWin32

PyWin32 [https://en.wikipedia.org/wiki/Component_Object_Model COM] Office Word Office === 9.5.2 Excelxlsxlsx ===

pyExcelerator

Home[http://sourceforge.net/projects/pyexcelerator/] Office Excel97/2000/XP/2003 OpenOffice Calc

PyWin32

PyWin32 [https://en.wikipedia.org/wiki/Component_Object_Model COM] Office Excel Office === 9.5.3 Power Pointpptpptx ===

python-pptx

Home[https://github.com/scanny/python-pptx] pptxOpen XML PowerPoint

PyWin32

PyWin32 [https://en.wikipedia.org/wiki/Component_Object_Model COM] Office Power Point Office == 9.6 RTF ==

PyRTF

Home[http://pyrtf.sourceforge.net/] RTF == 9.7 CHM ==

PyCHM

Home[http://gnochm.sourceforge.net/pychm.html] [http://www.jedrea.com/chmlib/ chmlib] Python CHM ---- = 10 = == 10.1 ==

Python Imaging LibraryPIL

Home[http://www.pythonware.com/products/pil/] Links[https://en.wikipedia.org/wiki/Python_Imaging_Library Wikipedia] Python BMPJPGGIFPNG ... ... JPEG import os, glob from PIL import Image size = 128, 128 for file in glob.glob("*.jpg"): name, ext = os.path.splitext(file) img = Image.open(file) img.thumbnail(size) img.save(name+".thumbnail", "JPEG") from PIL import Image img = Image.open("xxx.jpg") img = img.rotate(90) img.show()

Wand

Home[http://docs.wand-py.org/] ctypes [https://en.wikipedia.org/wiki/ImageMagick ImageMagick] ImageMagick from wand.image import Image from wand.display import display with Image(filename="mona-lisa.png") as img : print(img.size) for r in 1, 2, 3 : with img.clone() as new_img : new_img.resize(int(new_img.width/2), int(new_img.height/2)) new_img.rotate(90 * r) new_img.save(filename="mona-lisa-{0}.png".format(r)) display(new_img)

Pillow

Home[http://python-pillow.org/] PIL PIL PIL API

PyGraphviz

Home[https://github.com/pygraphviz/pygraphviz] [https://en.wikipedia.org/wiki/Graphviz Graphviz] [https://program-think.blogspot.com/2016/02/opensource-review-graphviz.html ] Python Graphviz SWIG

Graphviz

Home[https://github.com/xflr6/graphviz] Graphviz Python GitHub Star Fork DOT from graphviz import Digraph dot = Digraph(comment='The Round Table') # dot.node('A', 'King Arthur') dot.node('B', 'Sir Bedevere the Wise') dot.node('L', 'Sir Lancelot the Brave') # dot.edges(['AB', 'AL']) dot.edge('B', 'L', constraint='false') == 10.2 ==

Python Imaging LibraryPIL

PIL BMPJPGGIFPNG ...

Wand

Wand [https://en.wikipedia.org/wiki/ImageMagick ImageMagick] ImageMagick == 10.3 ==

Pycairo

Home[http://cairographics.org/pycairo/] [https://en.wikipedia.org/wiki/Cairo_%28graphics%29 Cairo] Win32 GDIOpenGLXlibXCBPDFPNGSVG...... Pycairo Cairo Python = 11 = == 11.1 ==

PyGame

Home[http://www.pygame.org/] Links[https://en.wikipedia.org/wiki/Pygame Wikipedia] [https://zh.wikipedia.org/wiki/Pygame ] [https://zh.wikipedia.org/wiki/SDL SDL]Simple DirectMedia Layer pySDL

Cocos2d

Home[http://cocos2d.org/] 2D Python GUI ... Cocos2d

Blender Game Engine

Home[http://www.blender.org/] Links[https://en.wikipedia.org/wiki/Game_Blender Wikipedia] [https://zh.wikipedia.org/wiki/Game_Blender ] [https://en.wikipedia.org/wiki/Blender_%28software%29 Blender] C++ Python 3D AI ... == 11.2 3D ==

PyOpenGL

Home[http://pyopengl.sourceforge.net/] [https://en.wikipedia.org/wiki/OpenGL OpenGL] Python

Python-Ogre

Home[http://www.python-ogre.org/] [https://en.wikipedia.org/wiki/OGRE OGRE] Python ---- = 12 & =

NumPy

Home[http://www.numpy.org/] Links[https://en.wikipedia.org/wiki/NumPy Wikipedia] [https://zh.wikipedia.org/wiki/NumPy ] # Python a = range(10000000) b = range(10000000) c = [] for i in range(len(a)) : c.append(a[i] + b[i]) # NumPy import numpy as np a = np.arange(10000000) b = np.arange(10000000) c = a + b

SciPy

Home[http://www.scipy.org/] Links[https://en.wikipedia.org/wiki/SciPy Wikipedia] [https://zh.wikipedia.org/wiki/SciPy ] NumPy NumPy ...

SymPy

Home[http://sympy.org/] Links[https://en.wikipedia.org/wiki/SymPy Wikipedia] [https://zh.wikipedia.org/wiki/SymPy ] ...... ---- = 13 =

PyPy

Home[http://www.pypy.org/] Links[https://en.wikipedia.org/wiki/PyPy Wikipedia] [https://zh.wikipedia.org/wiki/PyPy ] Python Python PyPy JITJust-in-time compilation CPython
Web Proxy Viewer  |  New URL  |  Original Page