From 0aaa25a4094f92b9b7ac40aad7327acd44d42a4c Mon Sep 17 00:00:00 2001 From: programthink Date: Wed, 23 Dec 2015 23:58:58 +0800 Subject: [PATCH 01/62] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20Requests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/python.wiki | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/libs/python.wiki b/libs/python.wiki index 2dcacd8..bebdefe 100644 --- a/libs/python.wiki +++ b/libs/python.wiki @@ -394,6 +394,27 @@ 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

From 350cae4b95b9efa3243e089739a5db9ec659d709 Mon Sep 17 00:00:00 2001 From: programthink Date: Fri, 25 Dec 2015 23:37:25 +0800 Subject: [PATCH 02/62] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20libuv?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/cpp.wiki | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libs/cpp.wiki b/libs/cpp.wiki index ee9c385..fd9823f 100644 --- a/libs/cpp.wiki +++ b/libs/cpp.wiki @@ -1459,7 +1459,7 @@ Home:[http://c-ares.haxx.se/] === 7.3.4 XMPP === -(XMPP 的洋文全称是“Extensible Messaging and Presence Protocol”。这是一个标准化的 IM 交互协议) +([https://zh.wikipedia.org/wiki/XMPP XMPP] 的洋文全称是“Extensible Messaging and Presence Protocol”。这是一个标准化的 IM 交互协议)

Swiften

@@ -1692,6 +1692,16 @@ Home:[http://libev.schmorp.de/] [http://www.gevent.org/ gevent] 官方博客的[http://blog.gevent.org/2011/04/28/libev-and-libevent/ 一篇文章]对比了这俩库的优缺点。 +

libuv

+ +Home:[https://github.com/libuv/libuv] + +Wikipedia:[https://en.wikipedia.org/wiki/Libuv 英文] + +它提供了跨平台的异步 I/O 机制。主要是为了提供给 [https://en.wikipedia.org/wiki/Node.js Node.js] 使用。 + +除了支持网络通讯,还支持:线程池、Windows 命名管道、Unix domain sockets、文件系统事件通知 ...... +

Dlib

Docs:[http://dlib.net/network.html] From 22339817825b327e38b045ee3607d6e20c2a4f67 Mon Sep 17 00:00:00 2001 From: programthink Date: Fri, 25 Dec 2015 23:50:30 +0800 Subject: [PATCH 03/62] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20hiberlite?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/cpp.wiki | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libs/cpp.wiki b/libs/cpp.wiki index fd9823f..ef55622 100644 --- a/libs/cpp.wiki +++ b/libs/cpp.wiki @@ -2266,6 +2266,12 @@ for(result::iterator i(r.begin()); i!=r.end(); ++i) trans.commit(); +

hiberlite

+ +Home:[https://github.com/paulftw/hiberlite] + +专门提供给 Sqlite 的 ORM 封装库。基于 C++ 开发,其 API 采用类似 Boost.Serialization 的风格。 + ---- = 9 Web = From e7ed27cc89d7d738a1a16eab747e74e3fd2317f9 Mon Sep 17 00:00:00 2001 From: programthink Date: Sat, 26 Dec 2015 00:30:25 +0800 Subject: [PATCH 04/62] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20WebSocket++?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/cpp.wiki | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libs/cpp.wiki b/libs/cpp.wiki index ef55622..352cd49 100644 --- a/libs/cpp.wiki +++ b/libs/cpp.wiki @@ -2403,6 +2403,16 @@ Wikipedia:[https://en.wikipedia.org/wiki/PhantomJS 英文] 它本身没有提供 GUI 界面。但是提供了 JavaScript 的 API,让你可以操纵 WebKit 引擎。可以利用它进行 Web 界面的单元测试。 +== 9.5 (其它) == + +

WebSocket++

+ +Home:[http://www.zaphoyd.com/websocketpp/] + +顾名思义,它提供了 [https://en.wikipedia.org/wiki/WebSocket WebSocket] 的 C++ 封装,基于 Boost Asio 构建。 + +支持多种操作系统平台,支持 TLS、proxy、IPv6。 + ---- = 10 信息安全 = From b2024b73abf6266fe7dbe1d646415246082c1844 Mon Sep 17 00:00:00 2001 From: programthink Date: Sat, 27 Feb 2016 23:53:25 +0800 Subject: [PATCH 05/62] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20PyGraphviz?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/python.wiki | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libs/python.wiki b/libs/python.wiki index bebdefe..6d30bcf 100644 --- a/libs/python.wiki +++ b/libs/python.wiki @@ -1593,6 +1593,14 @@ with Image(filename="mona-lisa.png") as img : display(new_img) +

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 的封装。 + == 10.2 图像格式转换 ==

Python Imaging Library(PIL)

From b7c81a1072f5317c13fd60ef487d165df7c632b7 Mon Sep 17 00:00:00 2001 From: programthink Date: Sun, 28 Feb 2016 00:10:37 +0800 Subject: [PATCH 06/62] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20Graphviz?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/python.wiki | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/libs/python.wiki b/libs/python.wiki index 6d30bcf..6f4b7d8 100644 --- a/libs/python.wiki +++ b/libs/python.wiki @@ -1599,7 +1599,29 @@ 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 的封装。 +这个库如其名所示,提供了 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 图像格式转换 == From 6aabdb7142148eb133275152aa060d1849857111 Mon Sep 17 00:00:00 2001 From: programthink Date: Sun, 28 Feb 2016 23:19:59 +0800 Subject: [PATCH 07/62] =?UTF-8?q?=E5=8D=9A=E5=AE=A2=E9=93=BE=E6=8E=A5?= =?UTF-8?q?=E6=94=B9=E4=B8=BAHTTPS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/python.wiki | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libs/python.wiki b/libs/python.wiki index 6f4b7d8..10c1a72 100644 --- a/libs/python.wiki +++ b/libs/python.wiki @@ -8,7 +8,7 @@ 本页面列出的各种 Python 库/模块,如果注明了官网的网址,说明这个库是第三方的;否则就是 Python 语言内置的标准库。 -如果你发现本页面的开源库有错漏之处,非常欢迎给俺提供反馈——有 GitHub 帐号的同学,可以[https://github.com/programthink/opensource/issues 给俺发 issue];没帐号的同学,可以去[http://program-think.blogspot.com/ 俺博客]留言。 +如果你发现本页面的开源库有错漏之处,非常欢迎给俺提供反馈——有 GitHub 帐号的同学,可以[https://github.com/programthink/opensource/issues 给俺发 issue];没帐号的同学,可以去[https://program-think.blogspot.com/ 俺博客]留言。 ---- @@ -625,7 +625,7 @@ Python 标准库很早就提供了对 socket 编程的支持。 Home:[http://pycurl.sourceforge.net/] -[https://en.wikipedia.org/wiki/Curl cURL] 是一个功能很强的网络库/网络工具,支持 N 多应用层协议。俺在前几年写过一篇博文推荐它(在“[http://program-think.blogspot.com/2009/03/opensource-review-curl-library.html 这里]”)。 +[https://en.wikipedia.org/wiki/Curl cURL] 是一个功能很强的网络库/网络工具,支持 N 多应用层协议。俺在前几年写过一篇博文推荐它(在“[https://program-think.blogspot.com/2009/03/opensource-review-curl-library.html 这里]”)。 看名称就能猜到——PycURL 是 cURL 的 Python 封装。 @@ -705,7 +705,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/Protocol_Buffers 英文] 这是 Google 开发的一个跨语言的库,用于网络传输业务数据时的“编码/解码”。 -其优点是:跨多种语言、高性能、向前兼容、向后兼容。俺前几年写过一篇博文推荐 protobuf(在“[http://program-think.blogspot.com/2009/05/opensource-review-protocol-buffers.html 这里]”)。 +其优点是:跨多种语言、高性能、向前兼容、向后兼容。俺前几年写过一篇博文推荐 protobuf(在“[https://program-think.blogspot.com/2009/05/opensource-review-protocol-buffers.html 这里]”)。 作为 Protocol Buffers 的发明者,Google 默认实现了三种编程语言(C++、Java、Python)对它的支持。 @@ -898,7 +898,7 @@ Home:[https://pypi.python.org/pypi/ibm_db] sqlite3 从 Python 2.5 版本开始加入到标准库中。通过它,你可以很方便地操作 SQLite 数据库。 -[https://en.wikipedia.org/wiki/SQLite SQLite] 是一个很优秀的轻量级数据库,俺前几年写过一篇博文推荐它(在“[http://program-think.blogspot.com/2009/04/how-to-use-sqlite.html 这里]”)。 +[https://en.wikipedia.org/wiki/SQLite SQLite] 是一个很优秀的轻量级数据库,俺前几年写过一篇博文推荐它(在“[https://program-think.blogspot.com/2009/04/how-to-use-sqlite.html 这里]”)。 代码示例——创建一个内存数据库,建表并插入记录 @@ -1280,7 +1280,7 @@ Home:[http://code.enthought.com/chaco/] 它支持的哈希算法有:MD5 SHA1 SHA224 SHA256 SHA384 SHA512 -关于散列算法,俺写过一篇扫盲(在“[http://program-think.blogspot.com/2013/02/file-integrity-check.html 这里]”)。 +关于散列算法,俺写过一篇扫盲(在“[https://program-think.blogspot.com/2013/02/file-integrity-check.html 这里]”)。 代码示例——计算字符串的 SHA1 散列值 From fcb92149075fb06252a3503f337242b0f4cf15e0 Mon Sep 17 00:00:00 2001 From: programthink Date: Mon, 11 Apr 2016 23:24:43 +0800 Subject: [PATCH 08/62] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20PhysicsFS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/cpp.wiki | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libs/cpp.wiki b/libs/cpp.wiki index 352cd49..e3505a3 100644 --- a/libs/cpp.wiki +++ b/libs/cpp.wiki @@ -2639,6 +2639,16 @@ Home:[http://www.7-zip.org/sdk.html] 支持的格式:7z、LZMA、LZMA2、XZ +

PhysicsFS

+ +Home:[http://icculus.org/physfs/] + +Wikipedia:[https://en.wikipedia.org/wiki/PhysicsFS 英文] + +针对不同的压缩/归档格式,提供了类似 VFS 的抽象封装层。主要用于游戏开发中。 + +支持的格式:zip、7z、GRP、PAK、HOG、MVL、WAD... +

zopfli

Home:[https://github.com/google/zopfli] From 27260a49cdbbbb20687e975df8602fb4162d0c7d Mon Sep 17 00:00:00 2001 From: programthink Date: Mon, 11 Apr 2016 23:26:03 +0800 Subject: [PATCH 09/62] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20snappy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/cpp.wiki | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libs/cpp.wiki b/libs/cpp.wiki index e3505a3..34f0d94 100644 --- a/libs/cpp.wiki +++ b/libs/cpp.wiki @@ -2711,6 +2711,18 @@ Home:[http://www.unrarlib.org/] 该项目的开发已经停止。只支持对 RAR2 格式的解压缩。 +=== 11.2.7 snappy === + +

snappy

+ +Home:[https://google.github.io/snappy/] + +由 Google 开发的压缩格式,特点是非常快(不论是压缩还是解压);但是压缩率不如 gzip。 + +起先被用于 Google 内部的 BigTable,如今被用于多种 NoSQL 数据库(比如:Cassandra、Hadoop、LevelDB、MongoDB、RocksDB...) + +支持多种语言的绑定(C#、Common Lisp、Erlang、Go、Haskell、Lua、Java、Node.js、Perl、PHP、Python、R、Ruby、Smalltalk) + == 11.3 标记语言 == === 11.3.1 XML === From b6cfbfc486d982b7d8045a21d9abd90cca74996e Mon Sep 17 00:00:00 2001 From: programthink Date: Mon, 11 Apr 2016 23:27:00 +0800 Subject: [PATCH 10/62] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20Brotli?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/cpp.wiki | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libs/cpp.wiki b/libs/cpp.wiki index 34f0d94..53be113 100644 --- a/libs/cpp.wiki +++ b/libs/cpp.wiki @@ -2723,6 +2723,18 @@ Home:[https://google.github.io/snappy/] 支持多种语言的绑定(C#、Common Lisp、Erlang、Go、Haskell、Lua、Java、Node.js、Perl、PHP、Python、R、Ruby、Smalltalk) +=== 11.2.8 Brotli === + +

Brotli

+ +Home:[https://github.com/google/brotli] + +Wikipedia:[https://en.wikipedia.org/wiki/Brotli 英文] + +由 Google 开发的压缩格式,压缩率很高(据说高于 LZMA 和 bz2)。 + +该算法很新,是2015年9月才发布的。 + == 11.3 标记语言 == === 11.3.1 XML === From 9b0001e534039cff12aa4058dcb4a20058a63cde Mon Sep 17 00:00:00 2001 From: programthink Date: Sat, 21 May 2016 22:33:24 +0800 Subject: [PATCH 11/62] =?UTF-8?q?=E6=8F=8F=E8=BF=B0=E4=B8=AD=E6=B3=A8?= =?UTF-8?q?=E6=98=8E=E2=80=9C=E6=A0=87=E5=87=86=E5=BA=93=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/python.wiki | 138 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 110 insertions(+), 28 deletions(-) diff --git a/libs/python.wiki b/libs/python.wiki index 10c1a72..81fce7f 100644 --- a/libs/python.wiki +++ b/libs/python.wiki @@ -20,7 +20,9 @@

re

-正则表达式的标准库,提供基于正则的匹配和替换。 +【标准库】 + +提供基于正则的匹配和替换。 === 1.1.2 字符集 === @@ -42,12 +44,16 @@ print(chardet.detect(bytes))

StringIO & cStringIO

+【标准库】 + 以读写文件的方式来操作字符串(有点类似于内存文件)。 cStringIO 是 C 语言实现的,性能更高;而 StringIO 是 Python 实现的,提供 Unicode 兼容性。

difflib

+【标准库】 + 可以对两个字符串进行“按行”比较,其功能类似于命令行的 diff。 另外还支持“最佳匹配”功能——对给定的字符串 s 和字符串列表 l,在 l 里面找到最接近 s 的字符串。 @@ -60,7 +66,9 @@ cStringIO 是 C 语言实现的,性能更高;而 StringIO 是 Python 实现

base64

-标准库,提供 Base16、Base32、Base64 格式的编码和解码。 +【标准库】 + +提供 Base16、Base32、Base64 格式的编码和解码。 === 1.2.2 UUencode === @@ -68,7 +76,9 @@ cStringIO 是 C 语言实现的,性能更高;而 StringIO 是 Python 实现

uu

-标准库,提供 UUencode 格式的编码和解码。 +【标准库】 + +提供 UUencode 格式的编码和解码。 === 1.2.3 BinHex === @@ -76,16 +86,22 @@ cStringIO 是 C 语言实现的,性能更高;而 StringIO 是 Python 实现

binhex

-标准库,提供 BinHex 格式的编码和解码。 +【标准库】 + +提供 BinHex 格式的编码和解码。 == 1.3 数学类 ==

math

+【标准库】 + 顾名思义,这个标准库封装了常用的数学函数(开方、指数、对数、三角函数......)。

random

+【标准库】 + 顾名思义,这个标准库是用来进行随机数生成滴。 代码示例——生成 0-100 的随机数 @@ -97,7 +113,9 @@ random.randint(0, 100)

fractions

-这个标准库封装了跟有理数(分数)相关的运算 +【标准库】 + +封装了跟有理数(分数)相关的运算 == 1.4 容器 == @@ -191,11 +209,15 @@ Home:[http://pyobjc.sourceforge.net/]

os

-这是一个非常基本的标准库,提供了常见的操作系统相关功能,很多功能是针对文件系统。 +【标准库】 + +这是非常基本的标准库,提供了常见的操作系统相关功能,很多功能是针对文件系统。

shutil

-相对于 os 标准库,shutil 标准库提供了一些比较高级的文件和目录操作(目录递归复制、目录递归删除、目录压缩打包...) +【标准库】 + +相对于 os 而言,shutil 提供了一些比较高级的文件和目录操作(目录递归复制、目录递归删除、目录压缩打包...) 代码示例——递归删除某个目录 @@ -205,7 +227,9 @@ shutil.rmtree(xxxx)

glob

-这个标准库用于查找文件,【支持通配符】(* 和 ?) +【标准库】 + +用于查找文件,【支持通配符】(* 和 ?) 代码示例——获取当前目录所有 txt 文件 @@ -216,7 +240,9 @@ for file in glob.glob("./*.txt") :

fnmatch

-这个标准库用于匹配文件名(支持通配符,类似上面的 glob) +【标准库】 + +用于匹配文件名(支持通配符,类似上面的 glob) 代码示例——列出当前目录所有 txt 文件 @@ -229,7 +255,9 @@ for file in os.listdir(".") :

tempfile

-使用这个标准库,可以安全地生成临时文件或临时目录。 +【标准库】 + +使用它可以安全地生成临时文件或临时目录。 @@ -237,7 +265,9 @@ for file in os.listdir(".") :

threading

-这个模块提供了比较高层的线程封装 API。它本身包含了线程同步/互斥的机制。 +【标准库】 + +提供了比较高层的线程封装 API。它本身包含了线程同步/互斥的机制。 代码示例——基于“函数”的线程 @@ -275,7 +305,9 @@ if __name__ == "__main__" :

subprocess

-用于进程管理的标准库,可以启动子进程,通过标准输入输出跟子进程交互。 +【标准库】 + +用于进程管理,可以启动子进程,通过标准输入输出跟子进程交互。 代码示例——启动命令行进程,并获取该进程的标准输出 @@ -286,6 +318,8 @@ output = subprocess.check_output(["netstat", "-an"]) # 获取当前网络

multiprocessing

+【标准库】 + 它是 2.6 版本加入到标准库的,其 API 接口的风格类似于 threading 模块。 它本身包含了进程同步/互斥的机制。 @@ -309,6 +343,8 @@ if __name__ == "__main__" :

mmap

+【标准库】 + 提供了内存映射文件的支持。 代码示例——利用 mmap 在父子进程间交换数据 @@ -328,13 +364,17 @@ if pid == 0 : # 子进程

signal

+【标准库】 + 用于进程信号处理的标准库(主要用于 Linux & UNIX 系统)。 == 3.5 Linux & Unix 系统相关 ==

syslog

-通过这个标准库,可以很方便地跟 POSIX 的 syslog 服务进行交互。 +【标准库】 + +通过它可以很方便地跟 POSIX 的 syslog 服务进行交互。 == 3.6 Windows 系统相关 == @@ -382,6 +422,8 @@ Home:[https://pypi.python.org/pypi/setuptools]

httplib & httplib2 & http.request & urllib.parse

+【标准库】 + 这几个库可以进行各种 HTTP 客户端请求(GET、POST、等)。 Python2 的模块名是 httplib 和 httplib2;到 Python3,模块名改为 http.request 和 urllib.parse @@ -419,6 +461,8 @@ u'{"type":"User"...'

SimpleHTTPServer & http.server

+【标准库】 + 提供轻量级 HTTP Server 的标准库。 Python2 的模块名叫 SimpleHTTPServer;到 Python3 模块名改为 http.server @@ -527,6 +571,8 @@ Home:[https://github.com/chrivers/pyjaco]

webbrowser

+【标准库】 + 操纵当前系统的默认浏览器,访问指定 URL 的页面。 代码示例——用默认浏览器打开 Google 主页 @@ -654,7 +700,9 @@ body = buffer.getvalue()

ftplib

-封装 FTP 协议(文件传输)的标准库 +【标准库】 + +封装 FTP(File Transfer Protocol)协议 代码示例——列出 FTP 服务器上某目录的内容 @@ -671,15 +719,21 @@ ftp.quit()

smtplib

-封装 SMTP 协议(邮件发送)的标准库 +【标准库】 + +封装 SMTP(Simple Mail Transfer Protocol)协议

imaplib

-封装 IMAP 协议(邮件接收)的标准库 +【标准库】 + +封装 IMAP(Internet Message Access Protocol)协议

poplib

-封装 POP3 协议(邮件接收)的标准库 +【标准库】 + +封装 POP3(Post Office Protocol v3)协议 === 5.3.5 IM === @@ -896,6 +950,8 @@ Home:[https://pypi.python.org/pypi/ibm_db]

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 这里]”)。 @@ -1016,6 +1072,8 @@ Person.createTable()

Tkinter & tkinter

+【标准库】 + 这是 Python 内置的标准库,封装了 Tcl/Tk 界面库。 Python2 的模块名叫 Tkinter,到 Python3 模块名改为 tkinter @@ -1276,6 +1334,8 @@ Home:[http://code.enthought.com/chaco/]

hashlib

+【标准库】 + 在 Python 2.5 版本加入到标准库中。通过它,你可以很方便地计算各种散列值。 它支持的哈希算法有:MD5 SHA1 SHA224 SHA256 SHA384 SHA512 @@ -1327,14 +1387,18 @@ Home:[https://github.com/google/oauth2client] [https://en.wikipedia.org/wiki/Comma-separated_values CSV] 是一种历史悠久的结构化数据存储格式。其效果类似于一张数据库二维表。

csv

-标准库,提供 CSV 格式文件的读写。 +【标准库】 + +提供 CSV 格式文件的读写,可以手动指定行列分隔符。 === 9.1.2 JSON === JSON 格式源自 JavaScript,如今在 Web 开发中广为应用。

json

-标准库,提供 JSON 格式的编码和解码。 +【标准库】 + +提供 JSON 格式的编码和解码。 代码示例——编码/解码 JSON 字符串 @@ -1366,29 +1430,39 @@ pyyaml 提供了 Python 对 YAML 的封装。

zipfile

-处理 zip 格式的标准库。 +【标准库】 + +提供对 zip 格式的读写。 === 9.2.2 bzip2(bz2) ===

bz2

-处理 bzip2 格式的标准库。 +【标准库】 + +提供对 bzip2 格式的读写。 === 9.2.3 gzip(gz) ===

gzip

-处理 gzip 格式的标准库。 +【标准库】 + +提供对 gzip 格式的读写。

zlib

-处理 gzip 格式的标准库。 +【标准库】 + +提供对 zlib 格式的读写。 === 9.2.4 tar ===

tarfile

-处理 tar 格式的标准库。 +【标准库】 + +提供对 tar 格式的读写。 === 9.2.5 7zip(7z) === @@ -1410,7 +1484,9 @@ Home:[http://rarfile.berlios.de/]

msilib

-处理 msi 格式的标准库,从 Python 2.5 版本开始提供。 +【标准库】 + +提供对 msi 格式的读写,从 Python 2.5 版本开始加入标准库。 == 9.3 标记语言 == @@ -1418,11 +1494,15 @@ Home:[http://rarfile.berlios.de/]

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

-用 DOM(Document Object Model)方式处理 XML 文件的标准库。 +【标准库】 + +用 DOM(Document Object Model)方式处理 XML 文件。

xml.sax & xml.parsers.expat

-用 SAX(Simple API for XML)方式处理 XML 文件的标准库。 +【标准库】 + +用 SAX(Simple API for XML)方式处理 XML 文件。

lxml

@@ -1436,7 +1516,9 @@ Home:[http://lxml.de/]

HTMLParser

-以回调方式解析 HTML/XHTML 文件内容的标准库。 +【标准库】 + +以回调方式解析 HTML/XHTML 文件内容。 == 9.4 PDF == From f924371770a315e2f461b34f26d7ec23036f0061 Mon Sep 17 00:00:00 2001 From: programthink Date: Sat, 21 May 2016 22:35:51 +0800 Subject: [PATCH 12/62] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E5=B1=82=E7=BD=91=E7=BB=9C=E5=8D=8F=E8=AE=AE=E5=88=86=E7=B1=BB?= =?UTF-8?q?=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/python.wiki | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/python.wiki b/libs/python.wiki index 81fce7f..0bffb9f 100644 --- a/libs/python.wiki +++ b/libs/python.wiki @@ -696,7 +696,7 @@ body = buffer.getvalue() (关于“HTTP 协议”,请参见另一个大类:“Web”) -=== 5.3.3 FTP === +=== 5.3.3 文件传输 ===

ftplib

@@ -715,7 +715,7 @@ ftp.retrlines("LIST") # 列出当前目录的内容 ftp.quit() -=== 5.3.4 Email === +=== 5.3.4 电子邮件 ===

smtplib

@@ -735,7 +735,7 @@ ftp.quit() 封装 POP3(Post Office Protocol v3)协议 -=== 5.3.5 IM === +=== 5.3.5 即时通讯 ===

jabber.py

From 0278826104227b3b183dcab3d50c82a0f79e3d83 Mon Sep 17 00:00:00 2001 From: programthink Date: Sat, 21 May 2016 22:45:12 +0800 Subject: [PATCH 13/62] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20telnetlib?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/python.wiki | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/libs/python.wiki b/libs/python.wiki index 0bffb9f..9a9a3a3 100644 --- a/libs/python.wiki +++ b/libs/python.wiki @@ -749,6 +749,38 @@ Home:[https://bitbucket.org/jaraco/irc] IRC 是 Internet Relay Chat 的缩写。这是用 Python 封装的第三方库。 +=== 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() + + == 5.4 自定义的应用层 ==

Protocol Buffers

From 86dabe460786d18340fb48f673f9b40adf3a3b93 Mon Sep 17 00:00:00 2001 From: programthink Date: Sat, 21 May 2016 22:56:28 +0800 Subject: [PATCH 14/62] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20rdpy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/python.wiki | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libs/python.wiki b/libs/python.wiki index 9a9a3a3..fc2d9f5 100644 --- a/libs/python.wiki +++ b/libs/python.wiki @@ -781,6 +781,12 @@ 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 库 + == 5.4 自定义的应用层 ==

Protocol Buffers

From 516ee93f7bc793d14e382a789ba660fba922fbc1 Mon Sep 17 00:00:00 2001 From: programthink Date: Sat, 21 May 2016 23:05:51 +0800 Subject: [PATCH 15/62] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20urlparse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/python.wiki | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libs/python.wiki b/libs/python.wiki index fc2d9f5..ef0d82c 100644 --- a/libs/python.wiki +++ b/libs/python.wiki @@ -787,6 +787,14 @@ 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 库 +=== 5.3.7 (其它) === + +

urlparse

+ +【标准库】 + +用于解析 URL,提取各个部分的内容。从 Python 2.5 版本开始加入到标准库中,从 Python 2.7 开始支持包含 IPv6 的 URL + == 5.4 自定义的应用层 ==

Protocol Buffers

@@ -1861,7 +1869,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/SymPy 英文]、[https://zh.wikipedia ---- -= 13 其它 = += 13 (其它) = 一些不方便归类的,暂时放到这里。 From bd6f17824453aadb43561bdfc4542f56dd2419f3 Mon Sep 17 00:00:00 2001 From: programthink Date: Sat, 21 May 2016 23:21:54 +0800 Subject: [PATCH 16/62] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20pysftp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/python.wiki | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/libs/python.wiki b/libs/python.wiki index ef0d82c..cf9e33e 100644 --- a/libs/python.wiki +++ b/libs/python.wiki @@ -715,6 +715,22 @@ 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

@@ -772,8 +788,8 @@ tn.read_until("login: ") tn.write(user + "\n") if password : - tn.read_until("Password: ") - tn.write(password + "\n") + tn.read_until("Password: ") + tn.write(password + "\n") tn.write("ls\n") tn.write("exit\n") From 19219dfa449c6b52807408c643d3f2588ed92251 Mon Sep 17 00:00:00 2001 From: programthink Date: Sat, 16 Jul 2016 22:30:59 +0800 Subject: [PATCH 17/62] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20nanomsg?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/cpp.wiki | 46 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/libs/cpp.wiki b/libs/cpp.wiki index 53be113..c5a7fea 100644 --- a/libs/cpp.wiki +++ b/libs/cpp.wiki @@ -1552,7 +1552,7 @@ Home:[http://www.zeromq.org/] Wikipedia:[https://en.wikipedia.org/wiki/ZeroMQ 英文]、[https://zh.wikipedia.org/wiki/%C3%98MQ 中文] -ZeroMQ 是一个轻量级、跨平台的开源库,提供了高性能、异步的消息队列。它提供了多种语言的绑定(包括 C 和 C++)。 +ZeroMQ 是一个轻量级、跨平台的开源库,提供了高性能、异步的消息队列。采用 C++ 开发,提供了多种语言的绑定。 与传统的消息中间件不同,使用 ZeroMQ 不需要额外的“消息代理(message broker)”。 @@ -1584,6 +1584,50 @@ int main(int argc, char* argv[]) } +

nanomsg

+ +Home:[http://nanomsg.org/] + +很类似 ZeroMQ 的库,比 ZMQ 更加轻量级。采用 C 开发,提供了多种语言的绑定。 + +API 完全参照 BSD socket 的风格和语义。 + +代码示例——Request/Reply + +#include +#include +#include +#include +#include + +int reply(const char* url) +{ + int sock = nn_socket(AF_SP, NN_PULL); + assert(sock >= 0); + assert(nn_bind(sock, url) >= 0); + while(1) + { + char* msg = NULL; + int bytes = nn_recv(sock, &msg, NN_MSG, 0); + assert(bytes >= 0); + printf("RECEIVED:\n%s\n", msg); + nn_freemsg(msg); + } +} + +int request(const char* url, const char* msg) +{ + int sz_msg = strlen(msg) + 1; // '\0' + int sock = nn_socket(AF_SP, NN_PUSH); + assert(sock >= 0); + assert(nn_connect(sock, url) >= 0); + printf("SENDING:\n%s\n", msg); + int bytes = nn_send(sock, msg, sz_msg, 0); + assert(bytes == sz_msg); + return nn_shutdown(sock, 0); +} + +

ICE(Internet Communications Engine)

Home:[https://zeroc.com/] From 8d2fb83e88f53db10d4d5a6708cac53ad1a97817 Mon Sep 17 00:00:00 2001 From: programthink Date: Sat, 16 Jul 2016 22:45:24 +0800 Subject: [PATCH 18/62] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20PyZMQ?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/python.wiki | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libs/python.wiki b/libs/python.wiki index cf9e33e..5f3b0d4 100644 --- a/libs/python.wiki +++ b/libs/python.wiki @@ -884,6 +884,14 @@ gevent.joinall(jobs, timeout=2) print([job.value for job in jobs]) +

PyZMQ

+ +Home:[https://github.com/zeromq/pyzmq] + +这是 ZMQ(ZeroMQ)的 Python 封装库。同时支持 Python2 和 Python3。 + +PyZMQ 2.2 之后的版本同时支持 ZMQ 的 3.x 和 4.x 版本。 + ---- = 6 数据库 = From 1577625cd26f7c48ee7cf33a49e37ecf9585aa2c Mon Sep 17 00:00:00 2001 From: programthink Date: Sat, 16 Jul 2016 22:50:55 +0800 Subject: [PATCH 19/62] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20nanomsg-python?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/python.wiki | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/libs/python.wiki b/libs/python.wiki index 5f3b0d4..27ea139 100644 --- a/libs/python.wiki +++ b/libs/python.wiki @@ -892,6 +892,27 @@ Home:[https://github.com/zeromq/pyzmq] 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() + + ---- = 6 数据库 = From 193cca8f505eb6ad60fc5f4e6f5273d2f6f7f6d0 Mon Sep 17 00:00:00 2001 From: programthink Date: Wed, 27 Jul 2016 18:15:24 +0800 Subject: [PATCH 20/62] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20fmt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/cpp.wiki | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/libs/cpp.wiki b/libs/cpp.wiki index c5a7fea..b87e89a 100644 --- a/libs/cpp.wiki +++ b/libs/cpp.wiki @@ -304,6 +304,28 @@ cout << format("%s %d") % "price" % 1234; // price 1234 +

fmt

+ +Home:[https://github.com/fmtlib/fmt] + +这是一个轻量级、类型安全、高性能的字符串格式化库。它也可以用来替代 C++ 标准库中的 IOStreams。 + +代码示例 + +#include +#include + +// 使用 Python 的格式化语法 +fmt::print("Hello, {}!", "world"); +// 使用 printf 的格式化语法 +fmt::printf("Hello, %s!", "world"); +// 使用序号参数, +std::string s = fmt::format("{0} {1} {0}", "Hello", "world"); +// 使用命名参数 +fmt::print("Hello, {name}! The answer is {number}. Goodbye, {name}.", + fmt::arg("name", "World"), fmt::arg("number", 42)); + + === 2.3.3 正则表达式 ===

PCRE(Perl Compatible Regular Expressions)

From d928d2bddf48e63e317745f0f29c5170c55f41b3 Mon Sep 17 00:00:00 2001 From: programthink Date: Wed, 27 Jul 2016 18:31:15 +0800 Subject: [PATCH 21/62] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=86=E7=B1=BB?= =?UTF-8?q?=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/cpp.wiki | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/cpp.wiki b/libs/cpp.wiki index b87e89a..b4ca3c8 100644 --- a/libs/cpp.wiki +++ b/libs/cpp.wiki @@ -1076,7 +1076,7 @@ POCO 前面已经介绍过。它提供了相应的封装类(WinService), ---- -= 6 GUI = += 6 图形用户界面(GUI) = == 6.1 GUI 框架 == From c44d03fe8636d5b93defc65f4c45e7211ebd494d Mon Sep 17 00:00:00 2001 From: programthink Date: Wed, 27 Jul 2016 18:44:35 +0800 Subject: [PATCH 22/62] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20Boost.Program=5Fopti?= =?UTF-8?q?ons?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/cpp.wiki | 164 ++++++++++++++++++++++++++------------------------ 1 file changed, 87 insertions(+), 77 deletions(-) diff --git a/libs/cpp.wiki b/libs/cpp.wiki index b4ca3c8..a0a9a02 100644 --- a/libs/cpp.wiki +++ b/libs/cpp.wiki @@ -1297,9 +1297,19 @@ Home:[http://wxmathplot.sourceforge.net/] ---- -= 7 网络 = += 7 文本用户界面(TUI) = -== 7.1 链路层 & 网络层 == +== 7.1 命令行参数 == + +

Boost.Program_options

+ +Docs:[http://boost.org/libs/program_options] + +Boost 前面已经介绍过。这是 Boost 的其中一个子库,提供了“处理命令行参数”的功能。 + += 8 网络 = + +== 8.1 链路层 & 网络层 ==

libpcap

@@ -1374,7 +1384,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/Pcap 英文] 它是 libpcap 在 Windows 系统下的移植。 -== 7.2 传输层 == +== 8.2 传输层 ==

socket

@@ -1400,9 +1410,9 @@ Docs:[http://pocoproject.org/docs/Poco.Net.html] POCO 前面已经介绍过。它提供了针对 TCP 服务端的封装类。 -== 7.3 标准的应用层 == +== 8.3 标准的应用层 == -=== 7.3.1 综合性的库 === +=== 8.3.1 综合性的库 ===

cURL & libcurl

@@ -1465,11 +1475,11 @@ Docs:[http://pocoproject.org/docs/Poco.Net.html] POCO 前面已经介绍过。它提供了几种常见应用层协议(HTTP、SMTP、POP3、FTP、NTP ...)的封装类。 -=== 7.3.2 HTTP === +=== 8.3.2 HTTP === (关于“HTTP 协议”,请参见另一个大类:“Web 相关”) -=== 7.3.3 DNS === +=== 8.3.3 DNS ===

c-ares

@@ -1479,7 +1489,7 @@ Home:[http://c-ares.haxx.se/] 对比官网域名可知,它跟 cURL 是一家子。除了 cURL/libcurl 用到它,还有一些知名开源项目(比如:Wireshark、node.js ...)用到它。 -=== 7.3.4 XMPP === +=== 8.3.4 XMPP === ([https://zh.wikipedia.org/wiki/XMPP XMPP] 的洋文全称是“Extensible Messaging and Presence Protocol”。这是一个标准化的 IM 交互协议) @@ -1497,7 +1507,7 @@ Home:[https://github.com/qxmpp-project/qxmpp] 这是一个 C++ 语言开发的 XMPP 封装库。从它的名称可以看出——依赖了 Qt 框架(需要 Qt 4.5 或更高版本)。 -== 7.4 自定义的应用层 == +== 8.4 自定义的应用层 ==

Protocol Buffers

@@ -1523,7 +1533,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/Apache_Thrift 英文] (在这个方面,它有点类似于 Google 的 Protocol Buffers) -== 7.5 网络库、框架、中间件 == +== 8.5 网络库、框架、中间件 ==

Boost.Asio

@@ -1776,9 +1786,9 @@ Dlib 前面已经介绍过。它针对网络通讯,提供了比较高的抽象 ---- -= 8 数据库 = += 9 数据库 = -== 8.1 开源数据库 == +== 9.1 开源数据库 ==

MySQL

@@ -1868,9 +1878,9 @@ Home:[http://www.scylladb.com/] 号称性能提高10倍,并且延迟极低。 -== 8.2 数据库 API 的封装库 == +== 9.2 数据库 API 的封装库 == -=== 8.2.1 综合性的封装库 === +=== 9.2.1 综合性的封装库 ===

OTL

@@ -1922,7 +1932,7 @@ int main() } -=== 8.2.2 MySQL 封装库 === +=== 9.2.2 MySQL 封装库 ===

MySQL Connector C++

@@ -1992,7 +2002,7 @@ Docs:[http://pocoproject.org/docs/package-MySQL.MySQL.html] POCO 前面已经介绍过。它提供了 MySQL 的封装类 -=== 8.2.3 PostgreSQL 封装库 === +=== 9.2.3 PostgreSQL 封装库 ===

libpq

@@ -2036,7 +2046,7 @@ void update(const std::string& name) } -=== 8.2.4 Oracle 封装库 === +=== 9.2.4 Oracle 封装库 ===

OCILIB

@@ -2076,9 +2086,9 @@ int main() } -=== 8.2.5 DB2 封装库 === +=== 9.2.5 DB2 封装库 === -=== 8.2.6 SQLite 封装库 === +=== 9.2.6 SQLite 封装库 ===

官方的 C API

@@ -2137,7 +2147,7 @@ Docs:[http://pocoproject.org/docs/package-SQLite.SQLite.html] POCO 前面已经介绍过。它提供了 sqlite 的封装类 -=== 8.2.7 Redis 封装库 === +=== 9.2.7 Redis 封装库 ===

Hiredis

@@ -2209,7 +2219,7 @@ int main(int argc, char* argv[]) } -=== 8.2.8 MongoDB 封装库 === +=== 9.2.8 MongoDB 封装库 ===

官方的 C API

@@ -2257,7 +2267,7 @@ Docs:[http://pocoproject.org/docs/package-MongoDB.MongoDB.html] POCO 前面已经介绍过。它提供了 MongoDB 的封装类 -== 8.3 ODBC 相关 == +== 9.3 ODBC 相关 ==

unixODBC

@@ -2279,7 +2289,7 @@ Docs:[http://pocoproject.org/docs/package-ODBC.ODBC.html] POCO 前面已经介绍过。它提供了操作 ODBC 的封装类。 -== 8.4 ORM(Object-Relational Mapping) == +== 9.4 ORM(Object-Relational Mapping) ==

ODB

@@ -2340,9 +2350,9 @@ Home:[https://github.com/paulftw/hiberlite] ---- -= 9 Web = += 10 Web = -== 9.1 HTTP Server == +== 10.1 HTTP Server ==

Apache HTTP Server

@@ -2372,7 +2382,7 @@ Docs:[http://dlib.net/network.html#server_http] Dlib 前面已经介绍过。它提供了一个简单的 HTTP Server 的类(server_http)。 -== 9.2 HTTP Client == +== 10.2 HTTP Client ==

cURL & libcurl

@@ -2415,7 +2425,7 @@ Docs:[http://pocoproject.org/docs/package-Net.HTTPClient.html] POCO 前面已经介绍过。它提供了 HTTP Client 的封装类。 -== 9.3 浏览器引擎 == +== 10.3 浏览器引擎 ==

WebKit

@@ -2433,7 +2443,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/Gecko_(software) 英文]、[https://z 它是 Firefox 的渲染引擎,基于 C++ 开发,由 Mozilla 社区维护。 -== 9.4 浏览器整合 == +== 10.4 浏览器整合 ==

CEF(Chromium Embedded Framework)

@@ -2469,7 +2479,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/PhantomJS 英文] 它本身没有提供 GUI 界面。但是提供了 JavaScript 的 API,让你可以操纵 WebKit 引擎。可以利用它进行 Web 界面的单元测试。 -== 9.5 (其它) == +== 10.5 (其它) ==

WebSocket++

@@ -2481,9 +2491,9 @@ Home:[http://www.zaphoyd.com/websocketpp/] ---- -= 10 信息安全 = += 11 信息安全 = -== 10.1 密码学 == +== 11.1 密码学 ==

Crypto++

@@ -2599,11 +2609,11 @@ POCO 前面已经介绍过。它提供了常见的加密算法和哈希算法。 ---- -= 11 处理文件格式 = += 12 处理文件格式 = -== 11.1 结构化数据格式 == +== 12.1 结构化数据格式 == -=== 11.1.1 CSV === +=== 12.1.1 CSV === [https://en.wikipedia.org/wiki/Comma-separated_values CSV] 是一种历史悠久的结构化数据存储格式。其效果类似于一张数据库二维表。 @@ -2613,7 +2623,7 @@ Docs:[http://boost.org/libs/tokenizer] Boost 前面已经介绍过。这是 Boost 的其中一个子库,用来灵活地切割字符串。使用它,可以帮你提取 CSV 的行和列。 -=== 11.1.2 JSON === +=== 12.1.2 JSON === JSON 格式源自 JavaScript,如今在 Web 开发中广为应用。 @@ -2667,7 +2677,7 @@ Home:[https://github.com/open-source-parsers/jsoncpp] 如其名,这是个 C++ 的 JSON 封装库。 -=== 11.1.3 YAML === +=== 12.1.3 YAML === [https://en.wikipedia.org/wiki/YAML YAML] 是一种类似于 json 的结构化数据格式。它在确保可读性的基础上,提供了超越 json 的灵活性和扩展性。 @@ -2683,9 +2693,9 @@ Home:[http://pyyaml.org/wiki/LibYAML] C 语言实现的 YAML 解析器。 -== 11.2 压缩文件 & 打包文件 == +== 12.2 压缩文件 & 打包文件 == -=== 11.2.1 综合性的库 === +=== 12.2.1 综合性的库 ===

libarchive

@@ -2723,7 +2733,7 @@ Home:[https://github.com/google/zopfli] 压缩的速度比较慢,但是可以得到更高的压缩率。 -=== 11.2.2 zip === +=== 12.2.2 zip === [https://en.wikipedia.org/wiki/Zip_%28file_format%29 格式说明] @@ -2741,7 +2751,7 @@ Docs:[http://pocoproject.org/docs/Poco.Zip.html] POCO 前面已经介绍过。它提供了若干封装类,用于 zip 格式的压缩和解压。 -=== 11.2.3 bzip2(bz2) === +=== 12.2.3 bzip2(bz2) === [https://en.wikipedia.org/wiki/Bzip2 格式说明] @@ -2751,7 +2761,7 @@ Home:[http://bzip.org/] 这是 bzip2 官方提供的库,C 语言实现。 -=== 11.2.4 gzip(gz) === +=== 12.2.4 gzip(gz) ===

zlib

@@ -2761,7 +2771,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/Zlib 英文]、[https://zh.wikipedia. C 语言实现,诞生于1995年,被大量的开源项目使用(OpenSSL、OpenSSH、Apache、PostgreSQL、Git、libpng......)。 -=== 11.2.5 tar === +=== 12.2.5 tar ===

libtar

@@ -2769,7 +2779,7 @@ Home:[http://www.feep.net/libtar/] 基于 C 语言开发,可以对 tar 格式添加内容或读取内容。 -=== 11.2.6 rar === +=== 12.2.6 rar ===

unrarlib

@@ -2777,7 +2787,7 @@ Home:[http://www.unrarlib.org/] 该项目的开发已经停止。只支持对 RAR2 格式的解压缩。 -=== 11.2.7 snappy === +=== 12.2.7 snappy ===

snappy

@@ -2789,7 +2799,7 @@ Home:[https://google.github.io/snappy/] 支持多种语言的绑定(C#、Common Lisp、Erlang、Go、Haskell、Lua、Java、Node.js、Perl、PHP、Python、R、Ruby、Smalltalk) -=== 11.2.8 Brotli === +=== 12.2.8 Brotli ===

Brotli

@@ -2801,9 +2811,9 @@ Wikipedia:[https://en.wikipedia.org/wiki/Brotli 英文] 该算法很新,是2015年9月才发布的。 -== 11.3 标记语言 == +== 12.3 标记语言 == -=== 11.3.1 XML === +=== 12.3.1 XML ===

Expat

@@ -2839,7 +2849,7 @@ Home:[http://libxmlplusplus.sourceforge.net/] 如其名,它是针对前面提到的 libxml2 的 C++ 封装。 -=== 11.3.2 HTML === +=== 12.3.2 HTML ===

htmlcxx

@@ -2847,7 +2857,7 @@ Home:[http://htmlcxx.sourceforge.net/] 如其名,是基于 C++ 开发的。支持 HTML 和 CSS 的解析。 -== 11.4 PDF == +== 12.4 PDF ==

PoDoFo

@@ -2894,7 +2904,7 @@ HPDF_SaveToFile(doc, "test.pdf"); HPDF_Free(doc); -== 11.5 MS Office 文档 == +== 12.5 MS Office 文档 ==

wvWare

@@ -2904,7 +2914,7 @@ Home:[http://wvware.sourceforge.net/] AbiWord 和 KWord 用到它。 -== 11.6 RTF == +== 12.6 RTF ==

LibRTF

@@ -2912,7 +2922,7 @@ Home:[http://sourceforge.net/projects/librtf/] C 语言实现的库,可以解析 RTF 文件格式。 -== 11.7 CHM == +== 12.7 CHM ==

CHMLIB

@@ -2930,9 +2940,9 @@ Home:[http://www.mare.ee/indrek/libchmxx/] ---- -= 12 图像 = += 13 图像 = -== 12.1 图像处理 == +== 13.1 图像处理 ==

ImageMagick

@@ -2975,7 +2985,7 @@ Docs:[http://dlib.net/imaging.html] Dlib 前面已经介绍过。它提供了常见的图像处理功能(旋转、剪切、拉伸、过滤)。 -== 12.2 图像格式转换 == +== 13.2 图像格式转换 ==

ImageMagick

@@ -2983,7 +2993,7 @@ ImageMagick 前面已经介绍过。它支持非常多的图片格式([http:// 在支持的格式中,它可以实现其中几十种格式的相互转换。 -== 12.3 图像渲染 == +== 13.3 图像渲染 ==

Cairo

@@ -3017,7 +3027,7 @@ Home:[http://pbrt.org/] 基于光线追踪的物理渲染系统,采用 C++ 开发。 -== 12.4 计算机视觉 == +== 13.4 计算机视觉 ==

OpenCV

@@ -3031,9 +3041,9 @@ Wikipedia:[https://en.wikipedia.org/wiki/OpenCV 英文]、[https://zh.wikipedi ---- -= 13 多媒体 = += 14 多媒体 = -== 13.1 多媒体框架 == +== 14.1 多媒体框架 ==

FFmpeg

@@ -3063,7 +3073,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/Libav 英文] 它是2011年从 FFmpeg 派生出来的。基于 C 语言开发,支持多种操作系统。 -== 13.2 视频库 == +== 14.2 视频库 ==

libavcodec

@@ -3073,7 +3083,7 @@ Home:[http://ffmpeg.org/] 由于 Libav 从 FFmpeg 分裂出来,Libav 下也带有一个同名的库。 -== 13.3 音频库 == +== 14.3 音频库 ==

PortMedia & PortAudio

@@ -3093,9 +3103,9 @@ C 语言开发的 3D 音效库,跨平台。最初由 Loki Software 开发。Lo ---- -= 14 游戏 = += 15 游戏 = -== 14.1 综合性的游戏引擎 == +== 15.1 综合性的游戏引擎 ==

id Tech 系列

@@ -3141,7 +3151,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/Panda3D 英文] 以 C++ 编写,用 Python 脚本扩展。虽然它的名字有“3D”,但它不仅仅是 3D 引擎,还包括了其它功能(碰撞检测、音效、关卡编辑器...)。 -== 14.2 3D 渲染引擎 == +== 15.2 3D 渲染引擎 ==

OGRE

@@ -3161,7 +3171,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/Mesa_%28computer_graphics%29 英文] 使用 C 语言开发,它是针对 OpenGL 规范的【纯软件】实现(大部分 OpenGL 的实现都用到了显卡硬件)。 -== 14.3 物理引擎 == +== 15.3 物理引擎 ==

Bullet

@@ -3197,9 +3207,9 @@ Wikipedia:[https://en.wikipedia.org/wiki/Newton_Game_Dynamics 英文] ---- -= 15 数值运算 & 科学计算 = += 16 数值运算 & 科学计算 = -== 15.1 综合性的库 == +== 16.1 综合性的库 ==

GSL(GNU Scientific Library)

@@ -3219,7 +3229,7 @@ double y = gsl_sf_bessel_J0(x); printf("J0(%g) = %.18e\n", x, y); -== 15.2 有理数 == +== 16.2 有理数 ==

Boost.Rational

@@ -3227,7 +3237,7 @@ Docs:[http://boost.org/libs/rational] Boost 前面已经介绍过。这是 Boost 的其中一个子库,提供了“有理数”的功能。 -== 15.3 高精度数值运算 == +== 16.3 高精度数值运算 ==

GMP(GNU Multiple Precision)

@@ -3263,7 +3273,7 @@ Docs:[http://boost.org/libs/multiprecision] Boost 前面已经介绍过。这是 Boost 的其中一个子库,实现了高精度数值运算。它还提供了针对 GMP 的数据类型的封装。 -== 15.4 矩阵 == +== 16.4 矩阵 ==

Boost.uBLAS.Matrix

@@ -3292,7 +3302,7 @@ Docs:[http://dlib.net/linear_algebra.html#matrix] Dlib 前面已经介绍过。它提供了一个矩阵类。 -== 15.5 线性代数 == +== 16.5 线性代数 ==

Boost.uBLAS

@@ -3363,9 +3373,9 @@ Dlib 前面已经介绍过。它提供了线性代数相关的封装类。 ---- -= 16 跨语言编程 = += 17 跨语言编程 = -== 16.1 整合多种语言的库 == +== 17.1 整合多种语言的库 ==

SWIG

@@ -3377,9 +3387,9 @@ Wikipedia:[https://en.wikipedia.org/wiki/SWIG 英文] 整合之后,你的 C/C++ 程序就可以享受到其它这些语言的特性啦,非常爽! -== 16.2 整合单一语言的库 == +== 17.2 整合单一语言的库 == -=== 16.2.1 整合 Python 语言 === +=== 17.2.1 整合 Python 语言 ===

Boost.Python

@@ -3410,11 +3420,11 @@ BOOST_PYTHON_MODULE(hello_ext) ---- -= 17 (其它) = += 18 (其它) = 一些不方便归类的,暂时放到这里。 -== 17.1 词法分析 & 语法分析 == +== 18.1 词法分析 & 语法分析 ==

Boost.Spirit

From ab54928fcfb590c12e49154f417ef90c3d3d89a0 Mon Sep 17 00:00:00 2001 From: programthink Date: Wed, 27 Jul 2016 19:05:33 +0800 Subject: [PATCH 23/62] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20ncurses?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/cpp.wiki | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libs/cpp.wiki b/libs/cpp.wiki index a0a9a02..b36ce33 100644 --- a/libs/cpp.wiki +++ b/libs/cpp.wiki @@ -1307,6 +1307,18 @@ Docs:[http://boost.org/libs/program_options] Boost 前面已经介绍过。这是 Boost 的其中一个子库,提供了“处理命令行参数”的功能。 +== 7.2 文本终端 == + +

ncurses

+ +Home:[https://www.gnu.org/software/ncurses/] + +Wikipedia:[https://en.wikipedia.org/wiki/Ncurses 英文]、[https://zh.wikipedia.org/wiki/Ncurses 中文] + +ncurses 是“new curses”的缩略词,它是 [https://en.wikipedia.org/wiki/Curses_(programming_library) curses] 库的自由软件克隆,诞生于1993年。 + +大名鼎鼎的 [https://en.wikipedia.org/wiki/Eric_S._Raymond Eric S. Raymond] 曾参与早期版本的开发。 + = 8 网络 = == 8.1 链路层 & 网络层 == From e6dcdd25ef6017eca30b273b8385b6a227c29c22 Mon Sep 17 00:00:00 2001 From: programthink Date: Wed, 27 Jul 2016 19:30:46 +0800 Subject: [PATCH 24/62] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20getopt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/cpp.wiki | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/libs/cpp.wiki b/libs/cpp.wiki index b36ce33..a89f305 100644 --- a/libs/cpp.wiki +++ b/libs/cpp.wiki @@ -1301,12 +1301,86 @@ Home:[http://wxmathplot.sourceforge.net/] == 7.1 命令行参数 == +

getopt

+ +Home:[https://www.gnu.org/software/libc/manual/html_node/Getopt.html] + +Wikipedia:[https://en.wikipedia.org/wiki/Getopt 英文] + +这是标准C用来处理命令行参数的老牌函数,诞生于上世纪80年代初期。 + +它有很多种不同的实现,如今用得最多的是 GNU C Library 的实现。GNU 还实现了一个增强版 getopt_long。 + +代码示例 + +#include /* for printf */ +#include /* for exit */ +#include /* for getopt */ +int main(int argc, char** argv) +{ + int digit_optind = 0; + int aopt = 0, bopt = 0; + char* copt = NULL; + char* dopt = NULL; + int c; + while( (c = getopt(argc, argv, "abc:d:012")) != -1) + { + int this_option_optind = optind ? optind : 1; + switch(c) + { + case '0': + case '1': + case '2': + if(digit_optind != 0 && digit_optind != this_option_optind) + { + printf("digits occur in two different argv-elements.\n"); + } + digit_optind = this_option_optind; + printf("option %c\n", c); + break; + case 'a': + printf("option a\n"); + aopt = 1; + break; + case 'b': + printf("option b\n"); + bopt = 1; + break; + case 'c': + printf("option c with value '%s'\n", optarg); + copt = optarg; + break; + case 'd': + printf("option d with value '%s'\n", optarg); + dopt = optarg; + break; + case '?': + break; + default: + printf("?? getopt returned character code 0%o ??\n", c); + } + } + if(optind < argc) + { + printf("non-option ARGV-elements: "); + while(optind < argc) + { + printf("%s ", argv[optind++]); + } + printf("\n"); + } + exit (0); +} + +

Boost.Program_options

Docs:[http://boost.org/libs/program_options] Boost 前面已经介绍过。这是 Boost 的其中一个子库,提供了“处理命令行参数”的功能。 +它的功能很丰富,但是比较重型。 + == 7.2 文本终端 ==

ncurses

From 7642bda6930ea39356615f683e21607c3981f997 Mon Sep 17 00:00:00 2001 From: programthink Date: Wed, 15 Feb 2017 23:58:05 +0800 Subject: [PATCH 25/62] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20LZFSE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/cpp.wiki | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libs/cpp.wiki b/libs/cpp.wiki index a89f305..b434cda 100644 --- a/libs/cpp.wiki +++ b/libs/cpp.wiki @@ -2897,6 +2897,18 @@ Wikipedia:[https://en.wikipedia.org/wiki/Brotli 英文] 该算法很新,是2015年9月才发布的。 +=== 12.2.9 LZFSE === + +

LZFSE

+ +Home:[https://github.com/lzfse/lzfse] + +Wikipedia:[https://zh.wikipedia.org/wiki/LZFSE 中文] + +由苹果开发的压缩格式。苹果称它的压缩率与“ZLib level 5”相似,但速度快2至3倍。 + +该算法是前不久(2016年7月)才开源出来的。 + == 12.3 标记语言 == === 12.3.1 XML === From ec4d2d8d27d3059f27328fa210d7c219e36ecc75 Mon Sep 17 00:00:00 2001 From: programthink Date: Thu, 16 Feb 2017 00:33:05 +0800 Subject: [PATCH 26/62] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20gopy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/python.wiki | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libs/python.wiki b/libs/python.wiki index 27ea139..97ed8e8 100644 --- a/libs/python.wiki +++ b/libs/python.wiki @@ -193,7 +193,17 @@ Wikipedia:[https://en.wikipedia.org/wiki/IronPython 英文]、[https://zh.wiki 通过 IronPython 可以让 Python 代码运行在 dotNET 平台上,并且可以调用其它的 dotNET 语言的代码(C#、F#、VB.Net ...) -== 2.4 整合 Objective-C 语言 == +== 2.4 整合 Go == + +

gopy

+ +Home:[https://github.com/go-python/gopy] + +gopy 可以把 Go 源代码编译为 Python 的一个 module。 + +它提供了两种方式(命令行、Python 库)来实现:Go 源码编译为 Python 模块。 + +== 2.5 整合 Objective-C ==

PyObjC

From 905a6bc03aae748e700e26769b9b2c2b14c24d9a Mon Sep 17 00:00:00 2001 From: programthink Date: Thu, 16 Feb 2017 01:07:06 +0800 Subject: [PATCH 27/62] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20Plyvel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/python.wiki | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/libs/python.wiki b/libs/python.wiki index 97ed8e8..bf07147 100644 --- a/libs/python.wiki +++ b/libs/python.wiki @@ -1076,7 +1076,7 @@ Home:[https://github.com/andymccurdy/redis-py] 操作 Redis 的第三方 Python 客户端。 -代码示例——简单的 set/get +代码示例——简单的存取操作 import redis r = redis.StrictRedis(host="localhost", port=6379, db=0) @@ -1084,7 +1084,24 @@ r.set("foo", "bar") print(r.get("foo")) -=== 6.2.8 Berkeley DB === +=== 6.2.8 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.9 Berkeley DB ===

PyBSDDB

From cecc7cf4350e37cac5f1ac47f3e04c6a870ca90d Mon Sep 17 00:00:00 2001 From: programthink Date: Thu, 16 Feb 2017 01:20:40 +0800 Subject: [PATCH 28/62] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20PyMongo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/python.wiki | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/libs/python.wiki b/libs/python.wiki index bf07147..10be7f4 100644 --- a/libs/python.wiki +++ b/libs/python.wiki @@ -1068,7 +1068,15 @@ conn.commit() conn.close() -=== 6.2.7 Redis === +=== 6.2.7 MongoDB === + +

PyMongo

+ +Docs:[https://docs.mongodb.com/ecosystem/drivers/python/] + +这是 MongoDB 官方提供的 Python 驱动。 + +=== 6.2.8 Redis ===

redis-py

@@ -1084,7 +1092,7 @@ r.set("foo", "bar") print(r.get("foo")) -=== 6.2.8 LevelDB === +=== 6.2.9 LevelDB ===

Plyvel

@@ -1101,7 +1109,7 @@ print(db.get(b"key")) db.close() -=== 6.2.9 Berkeley DB === +=== 6.2.10 Berkeley DB ===

PyBSDDB

From 1db701e4cfcb4f1894e2c1028e45eb55f974316a Mon Sep 17 00:00:00 2001 From: programthink Date: Thu, 16 Feb 2017 01:46:53 +0800 Subject: [PATCH 29/62] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20HappyBase?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/python.wiki | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/libs/python.wiki b/libs/python.wiki index 10be7f4..4ec80da 100644 --- a/libs/python.wiki +++ b/libs/python.wiki @@ -1076,7 +1076,25 @@ Docs:[https://docs.mongodb.com/ecosystem/drivers/python/] 这是 MongoDB 官方提供的 Python 驱动。 -=== 6.2.8 Redis === +=== 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

@@ -1092,7 +1110,7 @@ r.set("foo", "bar") print(r.get("foo")) -=== 6.2.9 LevelDB === +=== 6.2.10 LevelDB ===

Plyvel

@@ -1109,7 +1127,7 @@ print(db.get(b"key")) db.close() -=== 6.2.10 Berkeley DB === +=== 6.2.11 Berkeley DB ===

PyBSDDB

From 4144e313f7a8caaaa7fd1cbfee41ec7d0dff3b04 Mon Sep 17 00:00:00 2001 From: programthink Date: Wed, 22 Feb 2017 22:13:48 +0800 Subject: [PATCH 30/62] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20Pillow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/python.wiki | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libs/python.wiki b/libs/python.wiki index 4ec80da..5c8ae8a 100644 --- a/libs/python.wiki +++ b/libs/python.wiki @@ -1819,6 +1819,14 @@ with Image(filename="mona-lisa.png") as img : display(new_img) +

Pillow

+ +Home:[http://python-pillow.org/] + +你可以把它视作“轻量级的 PIL”。 + +它的目标是比 PIL 更容易使用,并尽可能与 PIL 的 API 兼容。 +

PyGraphviz

Home:[https://github.com/pygraphviz/pygraphviz] From 4d42aa695307f8d9ca4f5fc5f6385cf6dfa11f9a Mon Sep 17 00:00:00 2001 From: programthink Date: Wed, 22 Feb 2017 22:18:14 +0800 Subject: [PATCH 31/62] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20Peewee?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/python.wiki | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/libs/python.wiki b/libs/python.wiki index 5c8ae8a..1efcedb 100644 --- a/libs/python.wiki +++ b/libs/python.wiki @@ -1204,6 +1204,38 @@ class Person(SQLObject) : Person.createTable() +

Peewee

+ +Home:[http://www.peewee-orm.com/] + +一个轻量级的 ORM,支持 SQLite、MySQL 和 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 = From 64d386d4b627db7cca5b323911f4ec3e74df5d87 Mon Sep 17 00:00:00 2001 From: programthink Date: Wed, 22 Feb 2017 22:24:48 +0800 Subject: [PATCH 32/62] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20Apache=20Libcloud?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/python.wiki | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/libs/python.wiki b/libs/python.wiki index 1efcedb..b23fe96 100644 --- a/libs/python.wiki +++ b/libs/python.wiki @@ -923,6 +923,29 @@ 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 数据库 = From 39b99b116f1349f37928093deb028807e944fb57 Mon Sep 17 00:00:00 2001 From: programthink Date: Wed, 22 Feb 2017 22:33:26 +0800 Subject: [PATCH 33/62] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20python-docx?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/python.wiki | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libs/python.wiki b/libs/python.wiki index b23fe96..10bd3bd 100644 --- a/libs/python.wiki +++ b/libs/python.wiki @@ -1775,6 +1775,14 @@ Home:[http://www.unixuser.org/~euske/python/pdfminer/] PyWin32 前面已经介绍过。它可以基于 [https://en.wikipedia.org/wiki/Component_Object_Model COM] 操作 Office 文档,包括 Word(本地需要安装 Office)。 +

python-docx

+ +Home:[https://github.com/python-openxml/python-docx] + +纯 python 实现的 docx 操作库,能够处理 docx 中的“文本、图片、样式”。 + +同时支持 Python2 和 Python3。 + === 9.5.2 Excel(xls、xlsx) ===

pyExcelerator

From c06baa82fc6f99fd8ea59eb18063e6b2e3b1da71 Mon Sep 17 00:00:00 2001 From: programthink Date: Wed, 22 Feb 2017 22:41:22 +0800 Subject: [PATCH 34/62] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20PyWin32=20=E7=9A=84?= =?UTF-8?q?=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/python.wiki | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/libs/python.wiki b/libs/python.wiki index 10bd3bd..a2b30ef 100644 --- a/libs/python.wiki +++ b/libs/python.wiki @@ -1771,10 +1771,6 @@ Home:[http://www.unixuser.org/~euske/python/pdfminer/] === 9.5.1 Word(doc、docx) === -

PyWin32

- -PyWin32 前面已经介绍过。它可以基于 [https://en.wikipedia.org/wiki/Component_Object_Model COM] 操作 Office 文档,包括 Word(本地需要安装 Office)。 -

python-docx

Home:[https://github.com/python-openxml/python-docx] @@ -1783,6 +1779,12 @@ Home:[https://github.com/python-openxml/python-docx] 同时支持 Python2 和 Python3。 +

PyWin32

+ +PyWin32 前面已经介绍过。它可以基于 [https://en.wikipedia.org/wiki/Component_Object_Model COM] 操作 Office 文档,包括 Word。 + +(本地需要安装 Office) + === 9.5.2 Excel(xls、xlsx) ===

pyExcelerator

@@ -1793,7 +1795,9 @@ Home:[http://sourceforge.net/projects/pyexcelerator/]

PyWin32

-PyWin32 前面已经介绍过。它可以基于 [https://en.wikipedia.org/wiki/Component_Object_Model COM] 操作 Office 文档,包括 Excel(本地需要安装 Office)。 +PyWin32 前面已经介绍过。它可以基于 [https://en.wikipedia.org/wiki/Component_Object_Model COM] 操作 Office 文档,包括 Excel。 + +(本地需要安装 Office) === 9.5.3 Power Point(ppt、pptx) === @@ -1805,7 +1809,9 @@ Home:[https://github.com/scanny/python-pptx]

PyWin32

-PyWin32 前面已经介绍过。它可以基于 [https://en.wikipedia.org/wiki/Component_Object_Model COM] 操作 Office 文档,包括 Excel(本地需要安装 Office)。 +PyWin32 前面已经介绍过。它可以基于 [https://en.wikipedia.org/wiki/Component_Object_Model COM] 操作 Office 文档,包括 Power Point。 + +(本地需要安装 Office) == 9.6 RTF == From 3d58249aa875de008c9d1b6af0268157852ac466 Mon Sep 17 00:00:00 2001 From: programthink Date: Sat, 25 Feb 2017 20:09:41 +0800 Subject: [PATCH 35/62] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=93=BE=E6=8E=A5?= =?UTF-8?q?=E6=96=87=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/python.wiki | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/libs/python.wiki b/libs/python.wiki index a2b30ef..8e7a667 100644 --- a/libs/python.wiki +++ b/libs/python.wiki @@ -161,7 +161,7 @@ MessageBox(text="Hello, world", flags=2) Home:[http://swig.org/] -Wikipedia:[https://en.wikipedia.org/wiki/SWIG 英文] +Links:[https://en.wikipedia.org/wiki/SWIG Wikipedia] 这是一个很老牌的、有名气的工具,它可以把多种语言(Java、Python、C#、Ruby、PHP、Perl、Lua、Go ...)整合到 C/C++ 中。 @@ -179,7 +179,7 @@ Home:[http://cython.org/] Home:[http://www.jython.org/] -Wikipedia:[https://en.wikipedia.org/wiki/Jython 英文]、[https://zh.wikipedia.org/wiki/Jython 中文] +Links:[https://en.wikipedia.org/wiki/Jython Wikipedia] [https://zh.wikipedia.org/wiki/Jython 维基百科] 通过 Jython 可以让 Python 代码运行在 JVM 上,并且可以调用其它的 JVM 语言的代码(比如 Java、Scala) @@ -189,7 +189,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/Jython 英文]、[https://zh.wikipedi Home:[http://ironpython.net/] -Wikipedia:[https://en.wikipedia.org/wiki/IronPython 英文]、[https://zh.wikipedia.org/wiki/IronPython 中文] +Links:[https://en.wikipedia.org/wiki/IronPython Wikipedia] [https://zh.wikipedia.org/wiki/IronPython 维基百科] 通过 IronPython 可以让 Python 代码运行在 dotNET 平台上,并且可以调用其它的 dotNET 语言的代码(C#、F#、VB.Net ...) @@ -408,7 +408,7 @@ PyInstaller 可以把你的 Python 代码制作成独立运行的程序(不依 Home:[http://www.py2exe.org/] -Wikipedia:[https://en.wikipedia.org/wiki/Py2exe 英文] +Links:[https://en.wikipedia.org/wiki/Py2exe Wikipedia] py2exe 的功能类似 PyInstaller,但只支持 Windows 平台。 @@ -496,7 +496,7 @@ httpd.serve_forever() Home:[https://www.djangoproject.com/] -Wikipedia:[https://en.wikipedia.org/wiki/Django_(web_framework) 英文]、[https://zh.wikipedia.org/wiki/Django 中文] +Links:[https://en.wikipedia.org/wiki/Django_(web_framework) Wikipedia] [https://zh.wikipedia.org/wiki/Django 维基百科] 在 Python 社区,Django 是目前最有影响力的 Web 开发框架。该框架很重型,内置了 Web 服务端开发常用的组件(比如:ORM、用户管理)。 @@ -508,7 +508,7 @@ Django 应用范围很广,比如 Google 的 Web 开发平台 GAE 就支持它 Home:[http://www.turbogears.org/] -Wikipedia:[https://en.wikipedia.org/wiki/TurboGears 英文]、[https://zh.wikipedia.org/wiki/TurboGears 中文] +Links:[https://en.wikipedia.org/wiki/TurboGears Wikipedia] [https://zh.wikipedia.org/wiki/TurboGears 维基百科] 又一个重型的 Web 开发框架,名气仅次于 Django。 @@ -518,7 +518,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/TurboGears 英文]、[https://zh.wiki Home:[http://www.cherrypy.org/] -Wikipedia:[https://en.wikipedia.org/wiki/CherryPy 英文] +Links:[https://en.wikipedia.org/wiki/CherryPy Wikipedia] 轻量级的 Web 框架。某些 Web 框架(比如前面提到的 TurboGears)使用它作为底层。 @@ -642,7 +642,7 @@ Home:[https://github.com/google/pywebsocket] Home:[http://www.secdev.org/projects/scapy/] -Wikipedia:[https://en.wikipedia.org/wiki/Scapy 英文] +Links:[https://en.wikipedia.org/wiki/Scapy Wikipedia] 这是一个底层的网络库,可以在不同协议层次构造网络数据包(包括链路层、网络层、传输层),还支持 Sniffer 抓包。 @@ -827,7 +827,7 @@ Home:[https://github.com/citronneur/rdpy] Home:[https://developers.google.com/protocol-buffers/] -Wikipedia:[https://en.wikipedia.org/wiki/Protocol_Buffers 英文] +Links:[https://en.wikipedia.org/wiki/Protocol_Buffers Wikipedia] 这是 Google 开发的一个跨语言的库,用于网络传输业务数据时的“编码/解码”。 @@ -839,7 +839,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/Protocol_Buffers 英文] Home:[https://thrift.apache.org/] -Wikipedia:[https://en.wikipedia.org/wiki/Apache_Thrift 英文] +Links:[https://en.wikipedia.org/wiki/Apache_Thrift Wikipedia] 来自于 Apache 社区,提供了一种跨语言的通讯机制。 @@ -853,7 +853,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/Apache_Thrift 英文] Home:[http://twistedmatrix.com/] -Wikipedia:[https://en.wikipedia.org/wiki/Twisted_%28software%29 英文] +Links:[https://en.wikipedia.org/wiki/Twisted_%28software%29 Wikipedia] 这是一个基于 Python 网络通讯开发框架,诞生于2002年,名气很大。 @@ -1164,7 +1164,7 @@ Home:[http://www.jcea.es/programacion/pybsddb.htm] Home:[http://www.sqlalchemy.org/] -Wikipedia:[https://en.wikipedia.org/wiki/SQLAlchemy 英文]、[https://zh.wikipedia.org/wiki/SQLAlchemy 中文] +Links:[https://en.wikipedia.org/wiki/SQLAlchemy Wikipedia] [https://zh.wikipedia.org/wiki/SQLAlchemy 维基百科] SQLAlchemy 支持的数据库有:MySQL、PostgreSQL、Sqlite、Oracle、MS SQL Server、Firebird、Sybase SQL Server、Informix、等。 @@ -1211,7 +1211,7 @@ Base.metadata.create_all(create_engine("dbms://user:pwd@host/dbname")) Home:[http://sqlobject.org/] -Wikipedia:[https://en.wikipedia.org/wiki/SQLObject 英文] +Links:[https://en.wikipedia.org/wiki/SQLObject Wikipedia] SQLObject 支持的数据库有:MySQL、PostgreSQL、Sqlite、MS SQL Server、Firebird、Sybase SQL Server、SAP DB、等。 @@ -1295,7 +1295,7 @@ if __name__ == "__main__" : Home:[http://www.wxpython.org/] -Wikipedia:[https://en.wikipedia.org/wiki/WxPython 英文]、[https://zh.wikipedia.org/wiki/WxPython 中文] +Links:[https://en.wikipedia.org/wiki/WxPython Wikipedia] [https://zh.wikipedia.org/wiki/WxPython 维基百科] 在所有的 wxWidgets 的 Python 封装库中,这个是名气最大的。 @@ -1333,7 +1333,7 @@ Home:[http://pythoncard.sourceforge.net/] Home:[http://www.pygtk.org/] -Wikipedia:[https://en.wikipedia.org/wiki/PyGTK 英文] +Links:[https://en.wikipedia.org/wiki/PyGTK Wikipedia] 它是 Python 对 GTK+2 的封装。 @@ -1411,7 +1411,7 @@ Gtk.main() Home:[http://www.riverbankcomputing.com/software/pyqt/] -Wikipedia:[https://en.wikipedia.org/wiki/PyQt 英文]、[https://zh.wikipedia.org/wiki/PyQt 中文] +Links:[https://en.wikipedia.org/wiki/PyQt Wikipedia] [https://zh.wikipedia.org/wiki/PyQt 维基百科] 这是 Python 对 Qt 的封装。 @@ -1495,7 +1495,7 @@ Home:[http://ocemp.sourceforge.net/gui.html] Home:[http://matplotlib.org/] -Wikipedia:[https://en.wikipedia.org/wiki/Matplotlib 英文] +Links:[https://en.wikipedia.org/wiki/Matplotlib Wikipedia] 这是一个有名的图形库,主要用来绘制数学相关的图形。 @@ -1839,7 +1839,7 @@ Home:[http://gnochm.sourceforge.net/pychm.html] Home:[http://www.pythonware.com/products/pil/] -Wikipedia:[https://en.wikipedia.org/wiki/Python_Imaging_Library 英文] +Links:[https://en.wikipedia.org/wiki/Python_Imaging_Library Wikipedia] 这是一个很有名气的 Python 图像处理库,支持常见图像文件格式(BMP、JPG、GIF、PNG ...)。 @@ -1954,7 +1954,7 @@ Pycairo 是 Cairo 官方提供 Python 封装。 Home:[http://www.pygame.org/] -Wikipedia:[https://en.wikipedia.org/wiki/Pygame 英文]、[https://zh.wikipedia.org/wiki/Pygame 中文] +Links:[https://en.wikipedia.org/wiki/Pygame Wikipedia] [https://zh.wikipedia.org/wiki/Pygame 维基百科] 这是名气很大的跨平台游戏引擎,构建于 [https://zh.wikipedia.org/wiki/SDL SDL](Simple DirectMedia Layer)之上。 @@ -1974,7 +1974,7 @@ Home:[http://cocos2d.org/] Home:[http://www.blender.org/] -Wikipedia:[https://en.wikipedia.org/wiki/Game_Blender 英文]、[https://zh.wikipedia.org/wiki/Game_Blender 中文] +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 脚本的扩展。 @@ -2002,7 +2002,7 @@ Home:[http://www.python-ogre.org/] Home:[http://www.numpy.org/] -Wikipedia:[https://en.wikipedia.org/wiki/NumPy 英文]、[https://zh.wikipedia.org/wiki/NumPy 中文] +Links:[https://en.wikipedia.org/wiki/NumPy Wikipedia] [https://zh.wikipedia.org/wiki/NumPy 维基百科] 它提供了功能强大、性能很高的数值数组,可以用来进行各种数值计算(包括矩阵运算)。 @@ -2026,7 +2026,7 @@ c = a + b Home:[http://www.scipy.org/] -Wikipedia:[https://en.wikipedia.org/wiki/SciPy 英文]、[https://zh.wikipedia.org/wiki/SciPy 中文] +Links:[https://en.wikipedia.org/wiki/SciPy Wikipedia] [https://zh.wikipedia.org/wiki/SciPy 维基百科] 它依赖 NumPy 提供的多维数组。相比 NumPy,它提供了更高层的数学运算模块(统计、线性代数、积分、常微分方程求解、傅立叶变换、信号处理 ...)。 @@ -2036,7 +2036,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/SciPy 英文]、[https://zh.wikipedia Home:[http://sympy.org/] -Wikipedia:[https://en.wikipedia.org/wiki/SymPy 英文]、[https://zh.wikipedia.org/wiki/SymPy 中文] +Links:[https://en.wikipedia.org/wiki/SymPy Wikipedia] [https://zh.wikipedia.org/wiki/SymPy 维基百科] 它是用来做符号计算的,其目标是成为一个全功能的“计算机代数系统”。 @@ -2052,7 +2052,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/SymPy 英文]、[https://zh.wikipedia Home:[http://www.pypy.org/] -Wikipedia:[https://en.wikipedia.org/wiki/PyPy 英文]、[https://zh.wikipedia.org/wiki/PyPy 中文] +Links:[https://en.wikipedia.org/wiki/PyPy Wikipedia] [https://zh.wikipedia.org/wiki/PyPy 维基百科] 它是一个用 Python 写的 Python 解释器(有点绕口令)。 From 24a7b0c54f42d890f5495b0ab6508474757c5aff Mon Sep 17 00:00:00 2001 From: programthink Date: Sat, 25 Feb 2017 20:28:39 +0800 Subject: [PATCH 36/62] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=93=BE=E6=8E=A5?= =?UTF-8?q?=E6=96=87=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/cpp.wiki | 158 +++++++++++++++++++++++++------------------------- 1 file changed, 79 insertions(+), 79 deletions(-) diff --git a/libs/cpp.wiki b/libs/cpp.wiki index b434cda..1cb842f 100644 --- a/libs/cpp.wiki +++ b/libs/cpp.wiki @@ -16,7 +16,7 @@ Home:[http://boost.org/] -Wikipedia:[https://en.wikipedia.org/wiki/Boost_%28C%2B%2B_libraries%29 英文]、[https://zh.wikipedia.org/wiki/Boost_C%2B%2B_Libraries 中文] +Links:[https://en.wikipedia.org/wiki/Boost_%28C%2B%2B_libraries%29 Wikipedia] [https://zh.wikipedia.org/wiki/Boost_C%2B%2B_Libraries 维基百科] Boost 大概是最重要的第三方 C++ 库。其作者有很多是 C++ 标准委员会的成员。Boost 的很多子库后来都成为 C++ 的标准库。 @@ -26,7 +26,7 @@ Boost 大概是最重要的第三方 C++ 库。其作者有很多是 C++ 标准 Home:[https://wxwidgets.org/] -Wikipedia:[https://en.wikipedia.org/wiki/WxWidgets 英文]、[https://zh.wikipedia.org/wiki/WxWidgets 中文] +Links:[https://en.wikipedia.org/wiki/WxWidgets Wikipedia] [https://zh.wikipedia.org/wiki/WxWidgets 维基百科] 这是一个非常老牌的 C++ 开源 GUI 框架,诞生于1992年。原先叫做 wxWindows,后来因为微软的法律纠纷,改为现名。 @@ -40,7 +40,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/WxWidgets 英文]、[https://zh.wikip Home:[http://www.qt-project.org/] -Wikipedia:[https://en.wikipedia.org/wiki/Qt_(toolkit) 英文]、[https://zh.wikipedia.org/wiki/Qt 中文] +Links:[https://en.wikipedia.org/wiki/Qt_(toolkit) Wikipedia] [https://zh.wikipedia.org/wiki/Qt 维基百科] 这是一个非常老牌的 C++ 开源 GUI 框架,于1995年发布 1.0 版本。原先由 Trolltech 公司维护,后来该公司被 Nokia 收购。 @@ -52,7 +52,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/Qt_(toolkit) 英文]、[https://zh.wi Home:[https://apr.apache.org/] -Wikipedia:[https://en.wikipedia.org/wiki/Apache_Portable_Runtime 英文]、[https://zh.wikipedia.org/wiki/Apache%E5%8F%AF%E7%A7%BB%E6%A4%8D%E8%BF%90%E8%A1%8C%E6%97%B6 中文] +Links:[https://en.wikipedia.org/wiki/Apache_Portable_Runtime Wikipedia] [https://zh.wikipedia.org/wiki/Apache%E5%8F%AF%E7%A7%BB%E6%A4%8D%E8%BF%90%E8%A1%8C%E6%97%B6 维基百科] 这是由 Apache 社区维护的 C 开源库,主要提供操作系统相关的功能(文件系统、进程、线程、用户、IPC)。此外还提供了一些网络相关的功能。 @@ -62,7 +62,7 @@ APR 原先是 Apache Web 服务器的一个组成部分,后来独立出来, Home:[http://www.cse.wustl.edu/~schmidt/ACE.html] -Wikipedia:[https://en.wikipedia.org/wiki/Adaptive_Communication_Environment 英文]、[https://zh.wikipedia.org/wiki/ACE%E8%87%AA%E9%80%82%E9%85%8D%E9%80%9A%E4%BF%A1%E7%8E%AF%E5%A2%83 中文] +Links:[https://en.wikipedia.org/wiki/Adaptive_Communication_Environment Wikipedia] [https://zh.wikipedia.org/wiki/ACE%E8%87%AA%E9%80%82%E9%85%8D%E9%80%9A%E4%BF%A1%E7%8E%AF%E5%A2%83 维基百科] 这是一个跨平台的 C++ 库,提供了一套网络通讯的框架;另外还支持线程、进程和 IPC。 @@ -70,7 +70,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/Adaptive_Communication_Environment Home:[http://pocoproject.org/] -Wikipedia:[https://en.wikipedia.org/wiki/POCO_C%2B%2B_Libraries 英文] +Links:[https://en.wikipedia.org/wiki/POCO_C%2B%2B_Libraries Wikipedia] 它的名称源自“POrtable COmponents”,是一个基于 C++ 的开源库。 @@ -80,7 +80,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/POCO_C%2B%2B_Libraries 英文] Home:[http://dlib.net/] -Wikipedia:[https://en.wikipedia.org/wiki/Dlib 英文] +Links:[https://en.wikipedia.org/wiki/Dlib Wikipedia] 诞生于2002年的 C++ 开源库,提供了非常多的功能(网络、多线程、GUI、数值计算、图像处理、数据挖掘......)。 @@ -90,7 +90,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/Dlib 英文] Home:[http://www.cryptopp.com/] -Wikipedia:[https://en.wikipedia.org/wiki/Crypto%2B%2B 英文] +Links:[https://en.wikipedia.org/wiki/Crypto%2B%2B Wikipedia] 它也叫“CryptoPP”或“libcrypto++”,是非常著名的开源加密库,诞生于1995年。基于 C++ 开发,大量用到模板语法。 @@ -332,7 +332,7 @@ fmt::print("Hello, {name}! The answer is {number}. Goodbye, {name}.", Home:[http://www.pcre.org/] -Wikipedia:[https://en.wikipedia.org/wiki/Perl_Compatible_Regular_Expressions 英文] +Links:[https://en.wikipedia.org/wiki/Perl_Compatible_Regular_Expressions Wikipedia] 这是一个很老牌的正则表达式的库,诞生于1997年。很多知名的开源项目(Apache、PHP、KDE)用到了它。 @@ -395,7 +395,7 @@ assert(i == 1234); Home:[http://www.geocities.jp/kosako3/oniguruma/] -Wikipedia:[https://en.wikipedia.org/wiki/Oniguruma 英文] +Links:[https://en.wikipedia.org/wiki/Oniguruma Wikipedia] 来自日本的正则式库,基于 C 语言。据说性能很高。 @@ -839,7 +839,7 @@ Boost 前面已经介绍过。这是 Boost 的其中一个子库,提供了与 Home:[https://github.com/google/googletest] -Wikipedia:[https://en.wikipedia.org/wiki/Google_Test 英文] +Links:[https://en.wikipedia.org/wiki/Google_Test Wikipedia] 这是 Google 提供的单元测试框架。从 Google Code 迁移到 GitHub 之后,又整合了 GoogleMock 项目。 @@ -849,7 +849,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/Google_Test 英文] Home:[http://freedesktop.org/wiki/Software/cppunit/] -Wikipedia:[https://en.wikipedia.org/wiki/CppUnit 英文] +Links:[https://en.wikipedia.org/wiki/CppUnit Wikipedia] 如其名,这是一个 C++ 的单元测试框架。该项目起先是作为 JUnit 的 C++ 移植而创建的。 @@ -857,7 +857,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/CppUnit 英文] Home:[http://check.sourceforge.net/] -Wikipedia:[https://en.wikipedia.org/wiki/Check_%28unit_testing_framework%29 英文] +Links:[https://en.wikipedia.org/wiki/Check_%28unit_testing_framework%29 Wikipedia] 这是针对 C 的单元测试框架。 @@ -1159,7 +1159,7 @@ int main(int argc, char* argv[]) Home:[http://www.gtk.org/] -Wikipedia:[https://en.wikipedia.org/wiki/GTK%2B 英文]、[https://zh.wikipedia.org/wiki/GTK%2B 中文] +Links:[https://en.wikipedia.org/wiki/GTK%2B Wikipedia] [https://zh.wikipedia.org/wiki/GTK%2B 维基百科] 老牌的 GUI 框架,诞生于1998年。原先叫做“GIMP Toolkit”,是基于 C 开发的跨平台界面组件库。 @@ -1196,7 +1196,7 @@ int main(int argc, char* argv[]) Home:[http://www.fltk.org/] -Wikipedia:[https://en.wikipedia.org/wiki/FLTK 英文]、[https://zh.wikipedia.org/wiki/FLTK 中文] +Links:[https://en.wikipedia.org/wiki/FLTK Wikipedia] [https://zh.wikipedia.org/wiki/FLTK 维基百科] 它的全称是“Fast, Light Toolkit”。如其名,它非常轻量级。用它写一个“Hello World 应用”,静态链接后大约才 100KB @@ -1227,7 +1227,7 @@ int main(int argc, char **argv) Home:[http://sourceforge.net/projects/wtl/] -Wikipedia:[https://en.wikipedia.org/wiki/Windows_Template_Library 英文]、[https://zh.wikipedia.org/wiki/Windows_Template_Library 中文] +Links:[https://en.wikipedia.org/wiki/Windows_Template_Library Wikipedia] [https://zh.wikipedia.org/wiki/Windows_Template_Library 维基百科] 这是微软雇员 Nenad Stefanovic 开发的开源 GUI 框架。开发 WTL 是为了提供一个轻量级的 MFC 替代品。 @@ -1305,7 +1305,7 @@ Home:[http://wxmathplot.sourceforge.net/] Home:[https://www.gnu.org/software/libc/manual/html_node/Getopt.html] -Wikipedia:[https://en.wikipedia.org/wiki/Getopt 英文] +Links:[https://en.wikipedia.org/wiki/Getopt Wikipedia] 这是标准C用来处理命令行参数的老牌函数,诞生于上世纪80年代初期。 @@ -1387,7 +1387,7 @@ Boost 前面已经介绍过。这是 Boost 的其中一个子库,提供了“ Home:[https://www.gnu.org/software/ncurses/] -Wikipedia:[https://en.wikipedia.org/wiki/Ncurses 英文]、[https://zh.wikipedia.org/wiki/Ncurses 中文] +Links:[https://en.wikipedia.org/wiki/Ncurses Wikipedia] [https://zh.wikipedia.org/wiki/Ncurses 维基百科] ncurses 是“new curses”的缩略词,它是 [https://en.wikipedia.org/wiki/Curses_(programming_library) curses] 库的自由软件克隆,诞生于1993年。 @@ -1401,7 +1401,7 @@ ncurses 是“new curses”的缩略词,它是 [https://en.wikipedia.org/wiki/ Home:[http://www.tcpdump.org/] -Wikipedia:[https://en.wikipedia.org/wiki/Pcap 英文] +Links:[https://en.wikipedia.org/wiki/Pcap Wikipedia] 很著名的 Sniffer 抓包库,基于 C 语言开发。 @@ -1466,7 +1466,7 @@ int main(int argc, char* argv[]) Home:[http://www.winpcap.org/] -Wikipedia:[https://en.wikipedia.org/wiki/Pcap 英文] +Links:[https://en.wikipedia.org/wiki/Pcap Wikipedia] 它是 libpcap 在 Windows 系统下的移植。 @@ -1504,7 +1504,7 @@ POCO 前面已经介绍过。它提供了针对 TCP 服务端的封装类。 Home:[http://curl.haxx.se/libcurl/] -Wikipedia:[https://en.wikipedia.org/wiki/CURL 英文]、[https://zh.wikipedia.org/wiki/CURL 中文] +Links:[https://en.wikipedia.org/wiki/CURL Wikipedia] [https://zh.wikipedia.org/wiki/CURL 维基百科] cURL 是一个功能很强的网络库/网络工具,支持 N 多应用层协议。下面是支持协议的列表(从它官网抄袭的) @@ -1599,7 +1599,7 @@ Home:[https://github.com/qxmpp-project/qxmpp] Home:[https://developers.google.com/protocol-buffers/] -Wikipedia:[https://en.wikipedia.org/wiki/Protocol_Buffers 英文] +Links:[https://en.wikipedia.org/wiki/Protocol_Buffers Wikipedia] 它是 Google 开发的一个跨语言的库,用于传输业务数据时的“编码/解码”。其优点是:跨多种语言、高性能、向前兼容、向后兼容。 @@ -1611,7 +1611,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/Protocol_Buffers 英文] Home:[https://thrift.apache.org/] -Wikipedia:[https://en.wikipedia.org/wiki/Apache_Thrift 英文] +Links:[https://en.wikipedia.org/wiki/Apache_Thrift Wikipedia] 来自于 Apache 社区,提供了一种跨语言的通讯机制。 @@ -1668,7 +1668,7 @@ ACE 前面已经介绍过。它提供了很多种用于网络通讯的设计模 Home:[http://www.zeromq.org/] -Wikipedia:[https://en.wikipedia.org/wiki/ZeroMQ 英文]、[https://zh.wikipedia.org/wiki/%C3%98MQ 中文] +Links:[https://en.wikipedia.org/wiki/ZeroMQ Wikipedia] [https://zh.wikipedia.org/wiki/%C3%98MQ 维基百科] ZeroMQ 是一个轻量级、跨平台的开源库,提供了高性能、异步的消息队列。采用 C++ 开发,提供了多种语言的绑定。 @@ -1750,7 +1750,7 @@ int request(const char* url, const char* msg) Home:[https://zeroc.com/] -Wikipedia:[https://en.wikipedia.org/wiki/Internet_Communications_Engine 英文]、[https://zh.wikipedia.org/wiki/ICE_(%E4%B8%AD%E9%97%B4%E4%BB%B6) 中文] +Links:[https://en.wikipedia.org/wiki/Internet_Communications_Engine Wikipedia] [https://zh.wikipedia.org/wiki/ICE_(%E4%B8%AD%E9%97%B4%E4%BB%B6) 维基百科] 这是一个面向对象的通讯中间件,诞生于2002年。支持不同编程语言的通讯。 @@ -1760,7 +1760,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/Internet_Communications_Engine 英文 Home:[http://libevent.org/] -Wikipedia:[https://en.wikipedia.org/wiki/Libevent 英文]、[https://zh.wikipedia.org/wiki/Libevent 中文] +Links:[https://en.wikipedia.org/wiki/Libevent Wikipedia] [https://zh.wikipedia.org/wiki/Libevent 维基百科] 它提供了异步事件处理机制。在网络开发中,可以用它替代传统的“event loop”,有助于简化代码。 @@ -1858,7 +1858,7 @@ Home:[http://libev.schmorp.de/] Home:[https://github.com/libuv/libuv] -Wikipedia:[https://en.wikipedia.org/wiki/Libuv 英文] +Links:[https://en.wikipedia.org/wiki/Libuv Wikipedia] 它提供了跨平台的异步 I/O 机制。主要是为了提供给 [https://en.wikipedia.org/wiki/Node.js Node.js] 使用。 @@ -1880,7 +1880,7 @@ Dlib 前面已经介绍过。它针对网络通讯,提供了比较高的抽象 Home:[https://www.mysql.com/] -Wikipedia:[https://en.wikipedia.org/wiki/MySQL 英文]、[https://zh.wikipedia.org/wiki/MySQL 中文] +Links:[https://en.wikipedia.org/wiki/MySQL Wikipedia] [https://zh.wikipedia.org/wiki/MySQL 维基百科] 名气最大的开源数据库,诞生于1995年,采用 C 和 C++ 语言开发。如今隶属于 Oracle 公司。 @@ -1888,7 +1888,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/MySQL 英文]、[https://zh.wikipedia Home:[http://postgresql.org/] -Wikipedia:[https://en.wikipedia.org/wiki/PostgreSQL 英文]、[https://zh.wikipedia.org/wiki/PostgreSQL 中文] +Links:[https://en.wikipedia.org/wiki/PostgreSQL Wikipedia] [https://zh.wikipedia.org/wiki/PostgreSQL 维基百科] 名气仅次于 MySQL 的开源数据库,诞生于1996年。采用 C 语言开发。 @@ -1896,7 +1896,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/PostgreSQL 英文]、[https://zh.wiki Home:[http://sqlite.org/] -Wikipedia:[https://en.wikipedia.org/wiki/SQLite 英文]、[https://zh.wikipedia.org/wiki/SQLite 中文] +Links:[https://en.wikipedia.org/wiki/SQLite Wikipedia] [https://zh.wikipedia.org/wiki/SQLite 维基百科] 它是一个很优秀的嵌入式(进程内)数据库,非常轻量级,支持各种作系统平台。采用 C 语言开发。 @@ -1906,7 +1906,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/SQLite 英文]、[https://zh.wikipedi Home:[https://www.mongodb.org/] -Wikipedia:[https://en.wikipedia.org/wiki/MongoDB 英文] +Links:[https://en.wikipedia.org/wiki/MongoDB Wikipedia] 这是近几年兴起的 NoSQL 数据库的一员。它本身是基于 C++ 和 C 开发的。 @@ -1914,7 +1914,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/MongoDB 英文] Home:[http://redis.io/] -Wikipedia:[https://zh.wikipedia.org/wiki/Redis 中文]、[https://en.wikipedia.org/wiki/Redis 英文] +Links:[https://zh.wikipedia.org/wiki/Redis 维基百科] [https://en.wikipedia.org/wiki/Redis Wikipedia] 诞生于2009年,是目前(2014~2015)最流行的键值存储数据库,基于 C 语言开发。 @@ -1924,7 +1924,7 @@ Wikipedia:[https://zh.wikipedia.org/wiki/Redis 中文]、[https://en.wikipedia Home:[http://www.oracle.com/us/products/database/berkeley-db/] -Wikipedia:[https://en.wikipedia.org/wiki/Berkeley_DB 英文]、[https://zh.wikipedia.org/wiki/Berkeley_DB 中文] +Links:[https://en.wikipedia.org/wiki/Berkeley_DB Wikipedia] [https://zh.wikipedia.org/wiki/Berkeley_DB 维基百科] 诞生于1994年,是一个很老牌的嵌入式(进程内)数据库,提供“键值存储”的功能,基于 C 语言开发。 @@ -1936,7 +1936,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/Berkeley_DB 英文]、[https://zh.wik Home:[https://github.com/google/leveldb] -Wikipedia:[https://en.wikipedia.org/wiki/LevelDB 英文]、[https://zh.wikipedia.org/wiki/LevelDB 中文] +Links:[https://en.wikipedia.org/wiki/LevelDB Wikipedia] [https://zh.wikipedia.org/wiki/LevelDB 维基百科] 它是 Google 基于 C++ 开发的 NoSQL 数据库,提供“键值存储”的功能。 @@ -1948,7 +1948,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/LevelDB 英文]、[https://zh.wikiped Home:[http://www.firebirdsql.org/] -Wikipedia:[https://en.wikipedia.org/wiki/Firebird_%28database_server%29 英文]、[https://zh.wikipedia.org/wiki/Firebird_(%E6%95%B0%E6%8D%AE%E5%BA%93) 中文] +Links:[https://en.wikipedia.org/wiki/Firebird_%28database_server%29 Wikipedia] [https://zh.wikipedia.org/wiki/Firebird_(%E6%95%B0%E6%8D%AE%E5%BA%93) 维基百科] 它是2000年的时候,从 [https://en.wikipedia.org/wiki/Borland Borland] 公司的 InterBase 数据库派生出来的。 @@ -1972,7 +1972,7 @@ Home:[http://www.scylladb.com/] Home:[http://otl.sourceforge.net/] -Wikipedia:[https://en.wikipedia.org/wiki/Oracle_Template_Library 英文] +Links:[https://en.wikipedia.org/wiki/Oracle_Template_Library Wikipedia] 原生支持的数据库:Oracle、SQL Server、DB2、Informix、TimesTen, MAX/DB;另支持 ODBC。 @@ -2359,7 +2359,7 @@ POCO 前面已经介绍过。它提供了 MongoDB 的封装类 Home:[http://www.unixodbc.org/] -Wikipedia:[https://en.wikipedia.org/wiki/UnixODBC 英文] +Links:[https://en.wikipedia.org/wiki/UnixODBC Wikipedia] 诞生于1999年,实现了全套的 ODBC 架构,包括:驱动管理器、相关的 GUI 界面和命令行界面。支持多种操作系统。 @@ -2381,7 +2381,7 @@ POCO 前面已经介绍过。它提供了操作 ODBC 的封装类。 Home:[http://www.codesynthesis.com/products/odb] -Wikipedia:[https://en.wikipedia.org/wiki/ODB_%28C%2B%2B%29 英文] +Links:[https://en.wikipedia.org/wiki/ODB_%28C%2B%2B%29 Wikipedia] 它的特色是:可以根据 C++ 类定义自动生成数据库的表结构。 @@ -2444,7 +2444,7 @@ Home:[https://github.com/paulftw/hiberlite] Home:[https://httpd.apache.org/] -Wikipedia:[https://en.wikipedia.org/wiki/Apache_HTTP_Server 英文]、[https://zh.wikipedia.org/wiki/Apache_HTTP_Server 中文] +Links:[https://en.wikipedia.org/wiki/Apache_HTTP_Server Wikipedia] [https://zh.wikipedia.org/wiki/Apache_HTTP_Server 维基百科] 大名鼎鼎的 Apache,诞生于1995年,采用 C 和 C++ 开发。长期作为 Web Server 市场份额的老大。 @@ -2452,7 +2452,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/Apache_HTTP_Server 英文]、[https:/ Home:[http://nginx.org/] -Wikipedia:[https://en.wikipedia.org/wiki/Nginx 英文]、[https://zh.wikipedia.org/wiki/Nginx 中文] +Links:[https://en.wikipedia.org/wiki/Nginx Wikipedia] [https://zh.wikipedia.org/wiki/Nginx 维基百科] Web Server 的后起之秀,诞生于2002年,采用 C 语言开发。其市场份额如今排名第二。 @@ -2517,7 +2517,7 @@ POCO 前面已经介绍过。它提供了 HTTP Client 的封装类。 Home:[https://www.webkit.org/] -Wikipedia:[https://en.wikipedia.org/wiki/WebKit 英文]、[https://zh.wikipedia.org/wiki/WebKit 中文] +Links:[https://en.wikipedia.org/wiki/WebKit Wikipedia] [https://zh.wikipedia.org/wiki/WebKit 维基百科] 它是很多浏览器使用的渲染引擎,基于 C++ 开发。 @@ -2525,7 +2525,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/WebKit 英文]、[https://zh.wikipedi Home:[https://developer.mozilla.org/] -Wikipedia:[https://en.wikipedia.org/wiki/Gecko_(software) 英文]、[https://zh.wikipedia.org/wiki/Gecko 中文] +Links:[https://en.wikipedia.org/wiki/Gecko_(software) Wikipedia] [https://zh.wikipedia.org/wiki/Gecko 维基百科] 它是 Firefox 的渲染引擎,基于 C++ 开发,由 Mozilla 社区维护。 @@ -2535,7 +2535,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/Gecko_(software) 英文]、[https://z Home:[https://bitbucket.org/chromiumembedded/cef] -Wikipedia:[https://en.wikipedia.org/wiki/Chromium_Embedded_Framework 英文] +Links:[https://en.wikipedia.org/wiki/Chromium_Embedded_Framework Wikipedia] 如其名,它提供了嵌入 Chrome 浏览器的框架。采用 C++ 开发。好几个商业公司(Google、Adobe、Facebook、Evernote...)的产品用到它。 @@ -2559,7 +2559,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/Chromium_Embedded_Framework 英文] Home:[http://phantomjs.org/] -Wikipedia:[https://en.wikipedia.org/wiki/PhantomJS 英文] +Links:[https://en.wikipedia.org/wiki/PhantomJS Wikipedia] 2011年才诞生的。基于 C++ 开发,整合了 WebKit。 @@ -2603,7 +2603,7 @@ SHA256().CalculateDigest(abDigest, pbData, nDataLen); Home:[https://www.openssl.org/] -Wikipedia:[https://en.wikipedia.org/wiki/OpenSSL 英文]、[https://zh.wikipedia.org/wiki/OpenSSL 中文] +Links:[https://en.wikipedia.org/wiki/OpenSSL Wikipedia] [https://zh.wikipedia.org/wiki/OpenSSL 维基百科] OpenSSL 基于 C 语言开发,在加密领域那可是大名鼎鼎。大部分常用的加密算法(对称、非对称)和散列算法,它都支持。 @@ -2613,7 +2613,7 @@ OpenSSL 基于 C 语言开发,在加密领域那可是大名鼎鼎。大部分 Home:[http://www.libressl.org/] -Wikipedia:[https://en.wikipedia.org/wiki/LibreSSL 英文]、[https://zh.wikipedia.org/wiki/LibreSSL 中文] +Links:[https://en.wikipedia.org/wiki/LibreSSL Wikipedia] [https://zh.wikipedia.org/wiki/LibreSSL 维基百科] OpenSSL 爆出“心脏滴血漏洞”之后,OpenBSD 社区的程序员复制了 OpenSSL 版本 1.0.1g 的代码,然后另起炉灶。 @@ -2623,7 +2623,7 @@ LibreSSL 的主要目标是“安全性”,其维护人员删除了原 OpenSSL Home:[http://gnutls.org/] -Wikipedia:[https://en.wikipedia.org/wiki/GnuTLS 英文] +Links:[https://en.wikipedia.org/wiki/GnuTLS Wikipedia] 采用 C 语言开发,名气也挺大。如其名,主要提供 TLS/SSL 的相关功能。 @@ -2631,7 +2631,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/GnuTLS 英文] Home:[http://nacl.cr.yp.to/] -Wikipedia:[https://en.wikipedia.org/wiki/NaCl_%28software%29 英文] +Links:[https://en.wikipedia.org/wiki/NaCl_%28software%29 Wikipedia] 这个名称是“Networking and Cryptography library”的缩写。 @@ -2805,7 +2805,7 @@ Home:[http://www.7-zip.org/sdk.html] Home:[http://icculus.org/physfs/] -Wikipedia:[https://en.wikipedia.org/wiki/PhysicsFS 英文] +Links:[https://en.wikipedia.org/wiki/PhysicsFS Wikipedia] 针对不同的压缩/归档格式,提供了类似 VFS 的抽象封装层。主要用于游戏开发中。 @@ -2827,7 +2827,7 @@ Home:[https://github.com/google/zopfli] Home:[http://www.nih.at/libzip/] -Wikipedia:[https://en.wikipedia.org/wiki/Libzip 英文] +Links:[https://en.wikipedia.org/wiki/Libzip Wikipedia] 用 C 语言开发的库,基于 zlib 库。 @@ -2853,7 +2853,7 @@ Home:[http://bzip.org/] Home:[http://zlib.net/] -Wikipedia:[https://en.wikipedia.org/wiki/Zlib 英文]、[https://zh.wikipedia.org/wiki/Zlib 中文] +Links:[https://en.wikipedia.org/wiki/Zlib Wikipedia] [https://zh.wikipedia.org/wiki/Zlib 维基百科] C 语言实现,诞生于1995年,被大量的开源项目使用(OpenSSL、OpenSSH、Apache、PostgreSQL、Git、libpng......)。 @@ -2891,7 +2891,7 @@ Home:[https://google.github.io/snappy/] Home:[https://github.com/google/brotli] -Wikipedia:[https://en.wikipedia.org/wiki/Brotli 英文] +Links:[https://en.wikipedia.org/wiki/Brotli Wikipedia] 由 Google 开发的压缩格式,压缩率很高(据说高于 LZMA 和 bz2)。 @@ -2903,7 +2903,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/Brotli 英文] Home:[https://github.com/lzfse/lzfse] -Wikipedia:[https://zh.wikipedia.org/wiki/LZFSE 中文] +Links:[https://zh.wikipedia.org/wiki/LZFSE 维基百科] 由苹果开发的压缩格式。苹果称它的压缩率与“ZLib level 5”相似,但速度快2至3倍。 @@ -2917,7 +2917,7 @@ Wikipedia:[https://zh.wikipedia.org/wiki/LZFSE 中文] Home:[http://www.libexpat.org/] -Wikipedia:[https://en.wikipedia.org/wiki/Expat_(library) 英文] +Links:[https://en.wikipedia.org/wiki/Expat_(library) Wikipedia] 基于 C 语言实现,诞生于1998年。很多知名的开源项目(Apache Server、Firefox、Python、PHP、Perl)用到它。 @@ -2925,7 +2925,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/Expat_(library) 英文] Home:[http://xmlsoft.org/] -Wikipedia:[https://en.wikipedia.org/wiki/Libxml2 英文] +Links:[https://en.wikipedia.org/wiki/Libxml2 Wikipedia] 基于 C 语言实现,诞生于1999年。提供了多种语言(C++、Python、Ruby、Common Lisp、PHP、Perl)的 API 绑定。 @@ -2969,7 +2969,7 @@ Home:[http://podofo.sourceforge.net/] Home:[http://libharu.org/] -Wikipedia:[https://en.wikipedia.org/wiki/LibHaru 英文] +Links:[https://en.wikipedia.org/wiki/LibHaru Wikipedia] 它是基于 C 语言开发的跨平台库,可以用来生成 PDF 文件格式。 @@ -3046,7 +3046,7 @@ Home:[http://www.mare.ee/indrek/libchmxx/] Home:[http://imagemagick.org/] -Wikipedia:[https://en.wikipedia.org/wiki/ImageMagick 英文]、[https://zh.wikipedia.org/wiki/ImageMagick 中文] +Links:[https://en.wikipedia.org/wiki/ImageMagick Wikipedia] [https://zh.wikipedia.org/wiki/ImageMagick 维基百科] ImageMagick 可说是最强大的开源图片处理工具集,采用 C 语言编写。诞生于1990年,其开发至今依然非常活跃。支持非常多的操作系统平台。 @@ -3097,7 +3097,7 @@ ImageMagick 前面已经介绍过。它支持非常多的图片格式([http:// Home:[http://cairographics.org/] -Wikipedia:[https://en.wikipedia.org/wiki/Cairo_%28graphics%29 英文]、[https://zh.wikipedia.org/wiki/Cairo_(%E7%B9%AA%E5%9C%96) 中文] +Links:[https://en.wikipedia.org/wiki/Cairo_%28graphics%29 Wikipedia] [https://zh.wikipedia.org/wiki/Cairo_(%E7%B9%AA%E5%9C%96) 维基百科] 它提供了矢量图像的渲染功能。支持多种后端输出(Win32 GDI、OpenGL、Xlib、XCB、PDF、PNG、SVG ......)。 @@ -3113,7 +3113,7 @@ Home:[http://cairographics.org/cairomm/] Home:[https://github.com/google/skia] -Wikipedia:[https://en.wikipedia.org/wiki/Skia_Graphics_Engine 英文]、[https://zh.wikipedia.org/wiki/Skia_Graphics_Library 中文] +Links:[https://en.wikipedia.org/wiki/Skia_Graphics_Engine Wikipedia] [https://zh.wikipedia.org/wiki/Skia_Graphics_Library 维基百科] 它是 Google 基于 C++ 开发的图像渲染库。支持多种后端输出(rasterization、OpenGL、PDF、SVG、SWF ......)。 @@ -3131,7 +3131,7 @@ Home:[http://pbrt.org/] Home:[http://opencv.org/] -Wikipedia:[https://en.wikipedia.org/wiki/OpenCV 英文]、[https://zh.wikipedia.org/wiki/OpenCV 中文] +Links:[https://en.wikipedia.org/wiki/OpenCV Wikipedia] [https://zh.wikipedia.org/wiki/OpenCV 维基百科] 它是一个跨平台的计算机视觉库,由 Intel 发起并参与开发。开发语言是 C 和 C++。 @@ -3147,7 +3147,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/OpenCV 英文]、[https://zh.wikipedi Home:[http://ffmpeg.org/] -Wikipedia:[https://en.wikipedia.org/wiki/FFmpeg 英文]、[https://zh.wikipedia.org/wiki/FFmpeg 中文] +Links:[https://en.wikipedia.org/wiki/FFmpeg Wikipedia] [https://zh.wikipedia.org/wiki/FFmpeg 维基百科] 名气非常大的开源多媒体框架,基于 C 和汇编开发,支持多种操作系统。 @@ -3167,7 +3167,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/FFmpeg 英文]、[https://zh.wikipedi Home:[http://libav.org/] -Wikipedia:[https://en.wikipedia.org/wiki/Libav 英文] +Links:[https://en.wikipedia.org/wiki/Libav Wikipedia] 它是2011年从 FFmpeg 派生出来的。基于 C 语言开发,支持多种操作系统。 @@ -3187,7 +3187,7 @@ Home:[http://ffmpeg.org/] Home:[http://www.portaudio.com/] -Wikipedia:[https://en.wikipedia.org/wiki/PortAudio 英文] +Links:[https://en.wikipedia.org/wiki/PortAudio Wikipedia] PortAudio 是 PortMedia 的组成部分,提供了音频的播放和录制功能。支持多种底层 API(ALSA、DirectSound、WASAPI、ASIO...) @@ -3195,7 +3195,7 @@ PortAudio 是 PortMedia 的组成部分,提供了音频的播放和录制功 Home:[http://www.openal.org/] -Wikipedia:[https://en.wikipedia.org/wiki/OpenAL 英文]、[https://zh.wikipedia.org/wiki/OpenAL 中文] +Links:[https://en.wikipedia.org/wiki/OpenAL Wikipedia] [https://zh.wikipedia.org/wiki/OpenAL 维基百科] C 语言开发的 3D 音效库,跨平台。最初由 Loki Software 开发。Loki 倒闭以后,这个项目由开源社区继续维护。 @@ -3207,7 +3207,7 @@ C 语言开发的 3D 音效库,跨平台。最初由 Loki Software 开发。Lo

id Tech 系列

-Wikipedia:[https://en.wikipedia.org/wiki/Id_Tech 英文] +Links:[https://en.wikipedia.org/wiki/Id_Tech Wikipedia] 这个系列来自于大名鼎鼎的 [https://en.wikipedia.org/wiki/Id_Software id Software 公司],由同样大名鼎鼎约翰·卡马克打造。 @@ -3229,7 +3229,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/Id_Tech 英文] Home:[http://www.crystalspace3d.org/] -Wikipedia:[https://en.wikipedia.org/wiki/Crystal_Space 英文] +Links:[https://en.wikipedia.org/wiki/Crystal_Space Wikipedia] 以 C++ 编写,功能包括:2D 和 3D 渲染、音效、AI... 它的物理引擎基于 ODE 和 Bullet @@ -3237,7 +3237,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/Crystal_Space 英文] Home:[http://www.blender.org/] -Wikipedia:[https://en.wikipedia.org/wiki/Game_Blender 英文]、[https://zh.wikipedia.org/wiki/Game_Blender 中文] +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、... @@ -3245,7 +3245,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/Game_Blender 英文]、[https://zh.wi Home:[http://www.panda3d.org/] -Wikipedia:[https://en.wikipedia.org/wiki/Panda3D 英文] +Links:[https://en.wikipedia.org/wiki/Panda3D Wikipedia] 以 C++ 编写,用 Python 脚本扩展。虽然它的名字有“3D”,但它不仅仅是 3D 引擎,还包括了其它功能(碰撞检测、音效、关卡编辑器...)。 @@ -3255,7 +3255,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/Panda3D 英文] Home:[http://www.ogre3d.org/] -Wikipedia:[https://en.wikipedia.org/wiki/OGRE 英文]、[https://zh.wikipedia.org/wiki/OGRE 中文] +Links:[https://en.wikipedia.org/wiki/OGRE Wikipedia] [https://zh.wikipedia.org/wiki/OGRE 维基百科] 著名的 3D 渲染引擎,C++ 开发,诞生于2005年。支持很多操作系统(包括两大手机操作系统)。很多商业游戏用到它。 @@ -3265,7 +3265,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/OGRE 英文]、[https://zh.wikipedia. Home:[http://mesa3d.org/] -Wikipedia:[https://en.wikipedia.org/wiki/Mesa_%28computer_graphics%29 英文]、[https://zh.wikipedia.org/wiki/Mesa_3D 中文] +Links:[https://en.wikipedia.org/wiki/Mesa_%28computer_graphics%29 Wikipedia] [https://zh.wikipedia.org/wiki/Mesa_3D 维基百科] 使用 C 语言开发,它是针对 OpenGL 规范的【纯软件】实现(大部分 OpenGL 的实现都用到了显卡硬件)。 @@ -3275,7 +3275,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/Mesa_%28computer_graphics%29 英文] Home:[http://www.bulletphysics.org/] -Wikipedia:[https://en.wikipedia.org/wiki/Bullet_%28software%29 英文]、[https://zh.wikipedia.org/wiki/Bullet 中文] +Links:[https://en.wikipedia.org/wiki/Bullet_%28software%29 Wikipedia] [https://zh.wikipedia.org/wiki/Bullet 维基百科] 采用 C 和 C++ 开发。电影《2012》用到它,游戏“侠盗猎车手”、“荒野大镖客”用到它。 @@ -3283,7 +3283,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/Bullet_%28software%29 英文]、[http Home:[http://www.box2d.org/] -Wikipedia:[https://en.wikipedia.org/wiki/Box2D 英文]、[https://zh.wikipedia.org/wiki/Box2D 中文] +Links:[https://en.wikipedia.org/wiki/Box2D Wikipedia] [https://zh.wikipedia.org/wiki/Box2D 维基百科] 基于 C++ 开发的2维物理引擎。“愤怒的小鸟”用到它。 @@ -3291,7 +3291,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/Box2D 英文]、[https://zh.wikipedia Home:[http://www.ode.org/] -Wikipedia:[https://en.wikipedia.org/wiki/Open_Dynamics_Engine 英文]、[https://zh.wikipedia.org/wiki/Open_Dynamics_Engine 中文] +Links:[https://en.wikipedia.org/wiki/Open_Dynamics_Engine Wikipedia] [https://zh.wikipedia.org/wiki/Open_Dynamics_Engine 维基百科] 诞生于2001年,采用 C 和 C++ 开发。 @@ -3299,7 +3299,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/Open_Dynamics_Engine 英文]、[https Home:[http://www.newtondynamics.com/] -Wikipedia:[https://en.wikipedia.org/wiki/Newton_Game_Dynamics 英文] +Links:[https://en.wikipedia.org/wiki/Newton_Game_Dynamics Wikipedia] 基于 C++ 开发。 @@ -3313,7 +3313,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/Newton_Game_Dynamics 英文] Home:[https://www.gnu.org/software/gsl/] -Wikipedia:[https://en.wikipedia.org/wiki/GNU_Scientific_Library 英文] +Links:[https://en.wikipedia.org/wiki/GNU_Scientific_Library Wikipedia] 由 GNU 官方提供,包括:复数、多项式、矩阵、线性代数、特征向量、快速傅里叶变换、统计、模拟退火...... @@ -3341,7 +3341,7 @@ Boost 前面已经介绍过。这是 Boost 的其中一个子库,提供了“ Home:[https://gmplib.org/] -Wikipedia:[https://en.wikipedia.org/wiki/GNU_Multiple_Precision_Arithmetic_Library 英文]、[https://zh.wikipedia.org/wiki/GNU%E5%A4%9A%E9%87%8D%E7%B2%BE%E5%BA%A6%E8%BF%90%E7%AE%97%E5%BA%93 中文] +Links:[https://en.wikipedia.org/wiki/GNU_Multiple_Precision_Arithmetic_Library Wikipedia] [https://zh.wikipedia.org/wiki/GNU%E5%A4%9A%E9%87%8D%E7%B2%BE%E5%BA%A6%E8%BF%90%E7%AE%97%E5%BA%93 维基百科] 基于 C 语言的高精度数值运算库,诞生于1991年,非常老牌。 @@ -3431,7 +3431,7 @@ std::cout << v2 << std::endl; Home:[http://blitz.sourceforge.net/] -Wikipedia:[https://en.wikipedia.org/wiki/Blitz%2B%2B 英文] +Links:[https://en.wikipedia.org/wiki/Blitz%2B%2B Wikipedia] 它是基于 C++ 实现的。其特色是:采用“模板元编程”的技术进行编译时计算,从而优化了性能。 @@ -3439,7 +3439,7 @@ Wikipedia:[https://en.wikipedia.org/wiki/Blitz%2B%2B 英文] Home:[http://arma.sourceforge.net/] -Wikipedia:[https://en.wikipedia.org/wiki/Armadillo_%28C%2B%2B_library%29 英文] +Links:[https://en.wikipedia.org/wiki/Armadillo_%28C%2B%2B_library%29 Wikipedia] 类似 Blitz++,Armadillo 也用了“模板元编程”的技术。 @@ -3479,7 +3479,7 @@ Dlib 前面已经介绍过。它提供了线性代数相关的封装类。 Home:[http://swig.org/] -Wikipedia:[https://en.wikipedia.org/wiki/SWIG 英文] +Links:[https://en.wikipedia.org/wiki/SWIG Wikipedia] 这是一个很老牌的、有名气的工具,它可以把多种语言(Java、Python、C#、Ruby、PHP、Perl、Lua、Go ......)整合到 C/C++ 中。 From 32983f62e155b42239e720952a6e51a9fd45af53 Mon Sep 17 00:00:00 2001 From: programthink Date: Sat, 25 Feb 2017 20:56:44 +0800 Subject: [PATCH 37/62] =?UTF-8?q?=E7=BB=9F=E4=B8=80=E7=A4=BA=E4=BE=8B?= =?UTF-8?q?=E9=A3=8E=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/cpp.wiki | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/libs/cpp.wiki b/libs/cpp.wiki index 1cb842f..8ad9411 100644 --- a/libs/cpp.wiki +++ b/libs/cpp.wiki @@ -290,6 +290,7 @@ Boost 前面已经介绍过。这是 Boost 的其中一个子库,提供了“ #include #include + using std::cout; using boost::format; @@ -347,6 +348,7 @@ Boost 前面已经介绍过。这是 Boost 的其中一个子库,提供了“ 代码示例——基于正则式进行匹配和替换 #include + using std::string; using namespace boost; @@ -384,6 +386,7 @@ Home:[https://github.com/google/re2] 代码示例——基于正则式进行匹配 #include + int i; string s; assert(RE2::FullMatch("test:1234", "(\\w+):(\\d+)", &s, &i)); @@ -719,11 +722,13 @@ Boost 前面已经介绍过。这是 Boost 的其中一个子库,用来辅助 #include #include -boost::function f = std::atoi; -std::cout << f("42") << '\n'; +using namespace std; + +boost::function f = atoi; +cout << f("42") << '\n'; -f = std::strlen; -std::cout << f("42") << '\n'; +f = strlen; +cout << f("42") << '\n';

Boost.Lambda

@@ -741,10 +746,11 @@ Boost 前面已经介绍过。这是 Boost 的其中一个子库,提供了“ #include #include -std::vector v; +using namespace std; + +vector v; // 此处填充 v -std::for_each(v.begin(), v.end(), - std::cout << boost::lambda::_1 << "\n"); +for_each(v.begin(), v.end(), cout << boost::lambda::_1 << "\n"); == 3.4 元编程(Metaprogramming) == @@ -1316,7 +1322,8 @@ Links:[https://en.wikipedia.org/wiki/Getopt Wikipedia] #include /* for printf */ #include /* for exit */ #include /* for getopt */ -int main(int argc, char** argv) + +int main(int argc, char* argv[]) { int digit_optind = 0; int aopt = 0, bopt = 0; @@ -1410,7 +1417,7 @@ Links:[https://en.wikipedia.org/wiki/Pcap Wikipedia] #include #include -int main(int argc, char* argv[]) +int main() { pcap_t* handle; /* Session handle */ char* dev; /* The device to sniff on */ @@ -1680,7 +1687,7 @@ ZeroMQ 是一个轻量级、跨平台的开源库,提供了高性能、异步 #include -int main(int argc, char* argv[]) +int main() { zmq::context_t context(1); @@ -1772,7 +1779,6 @@ Links:[https://en.wikipedia.org/wiki/Libevent Wikipedia] [https://zh.wikipedia #include #include #include - #include #include @@ -1785,7 +1791,7 @@ void generic_request_handler(struct evhttp_request* req, void* arg) evbuffer_free(return_buffer); } -int main(int argc, char** argv) +int main() { short http_port = 8080; char* http_addr = "127.0.0.1"; @@ -2319,7 +2325,7 @@ MongoDB 前面已经介绍过。这是其官方提供的 API。 #include #include -int main(int argc, char* argv[]) +int main() { mongoc_init(); @@ -3415,7 +3421,9 @@ Boost 前面已经介绍过。这是 Boost 的其中一个子库,实现了 BLA #include #include +using namespace std; using namespace boost::numeric::ublas; + vector v(2); v(0) = 1; v(1) = 2; @@ -3424,7 +3432,7 @@ m(0,0) = 0; m(0,1) = 1; m(1,0) = 2; m(1,1) = 3; vector v2 = prod(m, v); -std::cout << v2 << std::endl; +cout << v2 << endl;

Blitz++

From 0b271b5746c5491c6a20d0e99d5691bab4e147b3 Mon Sep 17 00:00:00 2001 From: Benny Date: Thu, 11 Jan 2018 10:43:32 +0800 Subject: [PATCH 38/62] Update python.wiki --- libs/python.wiki | 174 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 174 insertions(+) diff --git a/libs/python.wiki b/libs/python.wiki index 8e7a667..fe8e84c 100644 --- a/libs/python.wiki +++ b/libs/python.wiki @@ -424,6 +424,50 @@ Home:[https://pypi.python.org/pypi/setuptools] 这套工具可以帮助你进行第三方库的管理(下载、编译、安装、升级、卸载) + +== 3.8 系统管理 == + +

sys

+【标准库】 + +这个模块可供访问由解释器使用或维护的变量和与解释器进行交互的函数。 + +代码示例 + +sys.argv # 命令行参数List,第一个元素是程序本身路径 +sys.exit(n) # 退出程序,正常退出时exit(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] + +psutil(Python system and process utilities)是一个跨平台的进程管理和系统工具的python库,可以处理系统CPU,memory,disks,network等信息。主要用于系统资源的监控,分析,以及对进程进行一定的管理。 + +代码示例 + +import psutil + +psutil.cpu_count() # 获取CPU数量 +psutil.cpu_freq()   # 获取CPU频率 +psutil.virtual_memory()     # 获取内存信息 + + ---- = 4 Web = @@ -561,6 +605,36 @@ if __name__ == "__main__" : 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/en/stable/] + +Links:[https://zh.wikipedia.org/wiki/Tornado] + +同样也是轻量级的Web框架,类似Web.py,但是异步非阻塞IO的处理方式使其拥有较为出色的抗负载能力。 + == 4.4 Web前端 & JS整合 ==

Pyjamas & pyjs

@@ -632,6 +706,34 @@ Home:[https://github.com/google/pywebsocket] 该项目包含一个可独立运行的 server 以及一个 Apache 扩展模块(mod_pywebsocket)。 +

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] +Scrapy是一个为了爬取网站数据,提取结构性数据而编写的应用框架。 可以应用在包括数据挖掘,信息处理或存储历史数据等一系列的程序中。 + + ---- = 5 网络 = @@ -761,6 +863,21 @@ with pysftp.Connection("hostxxx", username="userxxx", password="xxxxxx") as sftp 封装 POP3(Post Office Protocol v3)协议 +

yagmail

+ +Home:[https://github.com/kootenpv/yagmail] + +一个非常简单易用的用来发送邮件的第三方库。 + +代码示例 + +import yagmail +yag = yagmail.SMTP() +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

@@ -813,6 +930,22 @@ 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

@@ -1525,6 +1658,13 @@ Home:[http://code.enthought.com/chaco/] 这是一个商业公司维护的库,主要提供2维图表。效果图在“[http://docs.enthought.com/chaco/user_manual/annotated_examples.html 这里]”。 + +

Plotly

+ +Home:[https://plot.ly/d3-js-for-python-and-pandas-charts/] + +plotly是现代平台的敏捷商业智能和数据科学库,它作为一款开源的绘图库,可以应用于Python、R、MATLAB、Excel、JavaScript和jupyter等多种语言 + ---- = 8 信息安全 = @@ -1567,6 +1707,31 @@ Home:[https://github.com/google/keyczar] 它提供了比较高层的 API, 使用者无需关心太多的细节。 + +

passlib

+ +Home:[https://passlib.readthedocs.io/en/stable/index.html] + +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

@@ -1719,6 +1884,15 @@ Home:[http://lxml.de/] 以回调方式解析 HTML/XHTML 文件内容。 +

beautifulsoup

+ +Home:[https://www.crummy.com/software/BeautifulSoup/bs4/doc/] + +Links:[https://zh.wikipedia.org/zh-cn/Beautiful_Soup] + +Beautiful Soup 是一个可以从HTML 或XML 文件中提取数据的Python 库,爬虫利器,通常与requests或者selenium配合。 + + == 9.4 PDF ==

pyfpdf

From 0eb16637748810d95845d4b060093fa6c221573d Mon Sep 17 00:00:00 2001 From: Benny Date: Thu, 11 Jan 2018 10:45:49 +0800 Subject: [PATCH 39/62] Update python.wiki --- libs/python.wiki | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/python.wiki b/libs/python.wiki index fe8e84c..7a22d73 100644 --- a/libs/python.wiki +++ b/libs/python.wiki @@ -712,7 +712,7 @@ Home:[http://www.seleniumhq.org/] selenium是一个非常优秀的用于爬虫、Web自动化测试测试的框架。 -代码示例(模拟登录) +代码示例——模拟登录 from selenium import webdriver @@ -731,6 +731,7 @@ driver.quit() Home:[https://scrapy.org/] Links:[https://en.wikipedia.org/wiki/Scrapy] + Scrapy是一个为了爬取网站数据,提取结构性数据而编写的应用框架。 可以应用在包括数据挖掘,信息处理或存储历史数据等一系列的程序中。 From ddceeb343810b94ca2b03ad37094a15d693ae0e1 Mon Sep 17 00:00:00 2001 From: Benny Date: Thu, 11 Jan 2018 10:58:38 +0800 Subject: [PATCH 40/62] =?UTF-8?q?sys,=20platform,=20psutil,=20flask,=20tor?= =?UTF-8?q?nado,=20selenium=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sys, platform, psutil, flask, tornado, selenium, scrapy, yagmail, paramiko, plotly, passlib, beautifulsoup, telegram --- libs/python.wiki | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/libs/python.wiki b/libs/python.wiki index 7a22d73..651fe4d 100644 --- a/libs/python.wiki +++ b/libs/python.wiki @@ -893,6 +893,19 @@ 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] + +纯 Python 3 的 [https://telegram.org/ Telegram] 客户端封装。 + + === 5.3.6 远程控制 ===

telnetlib

@@ -1713,7 +1726,7 @@ Home:[https://github.com/google/keyczar] Home:[https://passlib.readthedocs.io/en/stable/index.html] -passlib是一个久经考验的非常成熟的跨平台的散列函数库,他所提供的功能包括随机盐密码的生成与验证,两步验证等。 +passlib是一个久经考验的非常成熟的跨平台的散列函数库,它所提供的功能包括随机盐密码的生成与验证,两步验证等。 代码示例——验证随机盐密码 From d1044390a9a0df4a47a32d97ccc0d82b1d4c350b Mon Sep 17 00:00:00 2001 From: programthink Date: Fri, 27 Apr 2018 22:10:57 +0800 Subject: [PATCH 41/62] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E7=A4=BA=E4=BE=8B?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=B8=AD=E7=9A=84=20HTML=20=E8=BD=AC?= =?UTF-8?q?=E4=B9=89=EF=BC=88=E8=B2=8C=E4=BC=BC=E4=B8=8D=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E4=BA=86=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/python.wiki | 116 ++++++++++++++++++++++------------------------- 1 file changed, 53 insertions(+), 63 deletions(-) diff --git a/libs/python.wiki b/libs/python.wiki index 651fe4d..825145a 100644 --- a/libs/python.wiki +++ b/libs/python.wiki @@ -296,7 +296,7 @@ threading.Thread(target=my_thread).start() import threading import time -from __future__ import print_function +from __future__ import print_function class MyThread(threading.Thread) : def run(self) : @@ -304,7 +304,7 @@ class MyThread(threading.Thread) : time.sleep(3) print("{} finished!".format(self.getName())) -if __name__ == "__main__" : +if __name__ == "__main__" : for n in range(10) : mythread = MyThread(name = "Thread-{}".format(n + 1)) mythread.start() @@ -322,8 +322,8 @@ if __name__ == "__main__" : 代码示例——启动命令行进程,并获取该进程的标准输出 import subprocess -output = subprocess.check_output(["dir"]) # 获取当前目录的内容 -output = subprocess.check_output(["netstat", "-an"]) # 获取当前网络链接 +output = subprocess.check_output(["dir"]) # 获取当前目录的内容 +output = subprocess.check_output(["netstat", "-an"]) # 获取当前网络链接

multiprocessing

@@ -343,7 +343,7 @@ def f(lock, n) : print("hello world %d" % n) lock.release() -if __name__ == "__main__" : +if __name__ == "__main__" : lock = Lock() for num in range(10): Process(target=f, args=(lock, num)).start() @@ -366,7 +366,7 @@ map = mmap.mmap(-1, 13) map.write("Hello, world") pid = os.fork() -if pid == 0 : # 子进程 +if pid == 0 : # 子进程 map.seek(0) print(map.readline()) map.close() @@ -424,10 +424,10 @@ Home:[https://pypi.python.org/pypi/setuptools] 这套工具可以帮助你进行第三方库的管理(下载、编译、安装、升级、卸载) - == 3.8 系统管理 ==

sys

+ 【标准库】 这个模块可供访问由解释器使用或维护的变量和与解释器进行交互的函数。 @@ -440,6 +440,7 @@ sys.version # 获取Python解释程序的版本信息

platform

+ 【标准库】 这个模块提供了很多用于获取操作系统的信息的功能。 @@ -600,7 +601,7 @@ class index: def GET(self): return "Hello, world!" -if __name__ == "__main__" : +if __name__ == "__main__" : app = web.application(urls, globals()) app.run() @@ -609,7 +610,7 @@ if __name__ == "__main__" : Home:[http://flask.pocoo.org/] -Links:[https://zh.wikipedia.org/wiki/Flask] +Links:[https://zh.wikipedia.org/wiki/Flask 维基百科] 轻量级Web应用框架。基于Werkzeug WSGI工具箱和Jinja2 模板引擎。 @@ -624,14 +625,13 @@ def hello_world(): if __name__ == '__main__': app.run() -

Tornado

Home:[http://www.tornadoweb.org/en/stable/] -Links:[https://zh.wikipedia.org/wiki/Tornado] +Links:[https://zh.wikipedia.org/wiki/Tornado 维基百科] 同样也是轻量级的Web框架,类似Web.py,但是异步非阻塞IO的处理方式使其拥有较为出色的抗负载能力。 @@ -677,15 +677,15 @@ import PyV8 ctxt1 = PyV8.JSContext() ctxt1.enter() -ctxt1.eval("1+2") # 对 JS 表达式求值 +ctxt1.eval("1+2") # 对 JS 表达式求值 -class Global(PyV8.JSClass) : # 定义一个兼容 JS 的类 +class Global(PyV8.JSClass) : # 定义一个兼容 JS 的类 def hello(self) : print("Hello, world") -ctxt2 = PyV8.JSContext(Global()) # 创建一个 JS 上下文,传入 Global 类的对象 +ctxt2 = PyV8.JSContext(Global()) # 创建一个 JS 上下文,传入 Global 类的对象 ctxt2.enter() -ctxt2.eval("hello()") # 调用 hello() 函数 +ctxt2.eval("hello()") # 调用 hello() 函数

PyWebKitGtk

@@ -714,27 +714,23 @@ 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] +Links:[https://en.wikipedia.org/wiki/Scrapy Wikipedia] Scrapy是一个为了爬取网站数据,提取结构性数据而编写的应用框架。 可以应用在包括数据挖掘,信息处理或存储历史数据等一系列的程序中。 - ---- = 5 网络 = @@ -753,10 +749,10 @@ Links:[https://en.wikipedia.org/wiki/Scapy Wikipedia] 代码示例 -# 传统的 ping 扫描(网络层) +# 传统的 ping 扫描(网络层) ans,unans = sr(IP(dst="192.168.1.1-254")/ICMP()) -# 局域网内的 ARP 扫描(链路层) +# 局域网内的 ARP 扫描(链路层) ans,unans = srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst="192.168.1.0/24"), timeout=2) @@ -821,10 +817,10 @@ body = buffer.getvalue() from ftplib import FTP -ftp = FTP("ftp.debian.org") # 连接服务器(如果不指定端口号,则用默认端口号 21) -ftp.login() # 登录(如果不指定用户名和密码,则用匿名登录) -ftp.cwd("debian") # 切换到 "debian" 目录 -ftp.retrlines("LIST") # 列出当前目录的内容 +ftp = FTP("ftp.debian.org") # 连接服务器(如果不指定端口号,则用默认端口号 21) +ftp.login() # 登录(如果不指定用户名和密码,则用匿名登录) +ftp.cwd("debian") # 切换到 "debian" 目录 +ftp.retrlines("LIST") # 列出当前目录的内容 ftp.quit() @@ -839,9 +835,9 @@ Home:[https://bitbucket.org/dundeemt/pysftp] 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") # 递归复制某个服务端的目录到本地 + with sftp.cd("public") # 服务端当前目录切换到 public + sftp.put("/my/local/filename") # 上传某个本地文件到服务端的 public 目录 + sftp.get_r("myfiles", "/local") # 递归复制某个服务端的目录到本地 === 5.3.4 电子邮件 === @@ -905,7 +901,6 @@ Home:[https://github.com/LonamiWebs/Telethon] 纯 Python 3 的 [https://telegram.org/ Telegram] 客户端封装。 - === 5.3.6 远程控制 ===

telnetlib

@@ -959,7 +954,6 @@ ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect("IP", port, "username", "password") - === 5.3.7 (其它) ===

urlparse

@@ -1057,7 +1051,7 @@ Home:[https://github.com/tonysimpson/nanomsg-python] 代码示例——Hello world -from __future__ import print_function +from __future__ import print_function from nanomsg import Socket, PAIR, PUB s1 = Socket(PAIR) @@ -1230,7 +1224,7 @@ sqlite3 从 Python 2.5 版本开始加入到标准库中。通过它,你可以 代码示例——创建一个内存数据库,建表并插入记录 import sqlite3 -conn = sqlite3.connect(":memory:") # ":memory:" 表示这是一个内存数据库 +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)") @@ -1324,7 +1318,7 @@ from sqlalchemy.orm import relation, sessionmaker Base = declarative_base() class Movie(Base) : - __tablename__ = "movies" + __tablename__ = "movies" id = Column(Integer, primary_key=True) title = Column(String(255), nullable=False) @@ -1332,23 +1326,23 @@ class Movie(Base) : directed_by = Column(Integer, ForeignKey("directors.id")) director = relation("Director", backref="movies", lazy=False) - def __init__(self, title=None, year=None) : + def __init__(self, title=None, year=None) : self.title = title self.year = year - def __repr__(self) : + def __repr__(self) : return "Movie(%r, %r, %r)" % (self.title, self.year, self.director) class Director(Base) : - __tablename__ = "directors" + __tablename__ = "directors" id = Column(Integer, primary_key=True) name = Column(String(50), nullable=False, unique=True) - def __init__(self, name=None) : + def __init__(self, name=None) : self.name = name - def __repr__(self) : + def __repr__(self) : return "Director(%r)" % (self.name) Base.metadata.create_all(create_engine("dbms://user:pwd@host/dbname")) @@ -1393,14 +1387,14 @@ class Person(Model) : birthday = DateField() is_relative = BooleanField() class Meta : - database = db # This model uses the "test.db". + 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". + database = db # This model uses the "test.db". db.connect() db.create_tables([Person, Pet]) @@ -1428,7 +1422,7 @@ Python2 的模块名叫 Tkinter,到 Python3 模块名改为 tkinter from Tkinter import * -if __name__ == "__main__" : +if __name__ == "__main__" : root = Tk() label = Label(root, text="Hello, world") label.pack() @@ -1462,7 +1456,7 @@ class App(wx.App) : self.SetTopWindow(self.frame) return True -if __name__ == "__main__" : +if __name__ == "__main__" : app = App() app.MainLoop() @@ -1491,7 +1485,7 @@ pygtk.require("2.0") import gtk class HelloWorld : - def __init__(self) : + def __init__(self) : self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.connect("delete_event", self.delete_event) self.window.connect("destroy", self.destroy) @@ -1518,7 +1512,7 @@ class HelloWorld : def destroy(self, widget, data=None) : gtk.main_quit() -if __name__ == "__main__" : +if __name__ == "__main__" : hello = HelloWorld() hello.main() @@ -1534,8 +1528,8 @@ Home:[https://live.gnome.org/PyGObject] from gi.repository import Gtk class MyWindow(Gtk.Window): - def __init__(self): - Gtk.Window.__init__(self, title="Hello World") + 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) @@ -1567,7 +1561,7 @@ Links:[https://en.wikipedia.org/wiki/PyQt Wikipedia] [https://zh.wikipedia.org import sys from PyQt4.QtGui import * -if __name__ == "__main__" : +if __name__ == "__main__" : app = QApplication(sys.argv) window = QWidget() @@ -1672,7 +1666,6 @@ Home:[http://code.enthought.com/chaco/] 这是一个商业公司维护的库,主要提供2维图表。效果图在“[http://docs.enthought.com/chaco/user_manual/annotated_examples.html 这里]”。 -

Plotly

Home:[https://plot.ly/d3-js-for-python-and-pandas-charts/] @@ -1721,7 +1714,6 @@ Home:[https://github.com/google/keyczar] 它提供了比较高层的 API, 使用者无需关心太多的细节。 -

passlib

Home:[https://passlib.readthedocs.io/en/stable/index.html] @@ -1745,7 +1737,6 @@ True False - == 8.2 访问控制 ==

oauth2client

@@ -1783,14 +1774,14 @@ JSON 格式源自 JavaScript,如今在 Web 开发中广为应用。 import json json.dumps(["foo", {"bar": ("baz", None, 1.0, 2)}]) -# JSON 编码 -# 得到如下【字符串】 -# """["foo", {"bar": ["baz", null, 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]}] +# JSON 解码 +# 得到如下【对象】 +# [u"foo", {u"bar": [u"baz", None, 1.0, 2]}] === 9.1.3 YAML === @@ -1902,11 +1893,10 @@ Home:[http://lxml.de/] Home:[https://www.crummy.com/software/BeautifulSoup/bs4/doc/] -Links:[https://zh.wikipedia.org/zh-cn/Beautiful_Soup] +Links:[https://zh.wikipedia.org/zh-cn/Beautiful_Soup 维基百科] Beautiful Soup 是一个可以从HTML 或XML 文件中提取数据的Python 库,爬虫利器,通常与requests或者selenium配合。 - == 9.4 PDF ==

pyfpdf

@@ -2105,11 +2095,11 @@ Home:[https://github.com/xflr6/graphviz] 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') @@ -2196,14 +2186,14 @@ Links:[https://en.wikipedia.org/wiki/NumPy Wikipedia] [https://zh.wikipedia.or 代码示例 -# 以下是传统 Python 写法,冗长且速度较慢 +# 以下是传统 Python 写法,冗长且速度较慢 a = range(10000000) b = range(10000000) c = [] for i in range(len(a)) : c.append(a[i] + b[i]) -# 以下是 NumPy 的写法,简洁且速度飞快 +# 以下是 NumPy 的写法,简洁且速度飞快 import numpy as np a = np.arange(10000000) b = np.arange(10000000) From 330a7d7261217f465c4c3de4fe7b05e1cf88c647 Mon Sep 17 00:00:00 2001 From: programthink Date: Fri, 27 Apr 2018 22:32:13 +0800 Subject: [PATCH 42/62] =?UTF-8?q?=E7=BB=9F=E4=B8=80=E7=A4=BA=E4=BE=8B?= =?UTF-8?q?=E9=A3=8E=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/python.wiki | 85 ++++++++++++++++++++++++------------------------ 1 file changed, 43 insertions(+), 42 deletions(-) diff --git a/libs/python.wiki b/libs/python.wiki index 825145a..ae59560 100644 --- a/libs/python.wiki +++ b/libs/python.wiki @@ -296,7 +296,7 @@ threading.Thread(target=my_thread).start() import threading import time -from __future__ import print_function +from __future__ import print_function class MyThread(threading.Thread) : def run(self) : @@ -304,7 +304,7 @@ class MyThread(threading.Thread) : time.sleep(3) print("{} finished!".format(self.getName())) -if __name__ == "__main__" : +if __name__ == "__main__" : for n in range(10) : mythread = MyThread(name = "Thread-{}".format(n + 1)) mythread.start() @@ -343,7 +343,7 @@ def f(lock, n) : print("hello world %d" % n) lock.release() -if __name__ == "__main__" : +if __name__ == "__main__" : lock = Lock() for num in range(10): Process(target=f, args=(lock, num)).start() @@ -434,9 +434,9 @@ Home:[https://pypi.python.org/pypi/setuptools] 代码示例 -sys.argv # 命令行参数List,第一个元素是程序本身路径 -sys.exit(n) # 退出程序,正常退出时exit(0) -sys.version # 获取Python解释程序的版本信息 +sys.argv # 命令行参数 List,第一个元素是程序本身路径 +sys.exit(0) # 退出程序,正常退出时用 0 表示退出码 +sys.version # 获取 Python 解释程序的版本信息

platform

@@ -449,9 +449,9 @@ sys.version # 获取Python解释程序的版本信息 import platform -platform.platform() # 获取操作系统名称及版本号,'Windows-7-6.1.7601-SP1' -platform.version() # 获取操作系统版本号,'6.1.7601' -platform.architecture() # 获取操作系统的位数,('32bit', 'WindowsPE') +platform.platform() # 获取操作系统名称及版本号,例如:"Windows-7-6.1.7601-SP1" +platform.version() # 获取操作系统版本号,例如:"6.1.7601" +platform.architecture() # 获取操作系统的架构,例如:("32bit", "WindowsPE")

psutil

@@ -464,9 +464,9 @@ psutil(Python system and process utilities)是一个跨平台的进程管理和 import psutil -psutil.cpu_count() # 获取CPU数量 -psutil.cpu_freq()   # 获取CPU频率 -psutil.virtual_memory()     # 获取内存信息 +psutil.cpu_count() # 获取 CPU 数量 +psutil.cpu_freq() # 获取 CPU 频率 +psutil.virtual_memory() # 获取内存信息 ---- @@ -571,8 +571,8 @@ Links:[https://en.wikipedia.org/wiki/CherryPy Wikipedia] import cherrypy -class HelloWorld(object): - def index(self): +class HelloWorld(object) : + def index(self) : return "Hello World!" index.exposed = True @@ -597,11 +597,11 @@ urls = ( "/", "index" ) -class index: - def GET(self): +class index : + def GET(self) : return "Hello, world!" -if __name__ == "__main__" : +if __name__ == "__main__" : app = web.application(urls, globals()) app.run() @@ -617,13 +617,13 @@ Links:[https://zh.wikipedia.org/wiki/Flask 维基百科] 代码示例——Hello world from flask import Flask -app = Flask(__name__) +app = Flask(__name__) -@app.route('/') -def hello_world(): - return 'Hello World!' +app.route("/") +def hello_world() : + return “Hello World!" -if __name__ == '__main__': +if __name__ == "__main__" : app.run() @@ -717,8 +717,8 @@ 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.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() @@ -869,10 +869,11 @@ Home:[https://github.com/kootenpv/yagmail] 代码示例 import yagmail + yag = yagmail.SMTP() -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) +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 即时通讯 === @@ -948,8 +949,8 @@ paramiko是用python语言写的一个模块,遵循SSH2协议,支持以加 代码示例 import paramiko -ssh = paramiko.SSHClient() +ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect("IP", port, "username", "password") @@ -1051,7 +1052,7 @@ Home:[https://github.com/tonysimpson/nanomsg-python] 代码示例——Hello world -from __future__ import print_function +from __future__ import print_function from nanomsg import Socket, PAIR, PUB s1 = Socket(PAIR) @@ -1318,7 +1319,7 @@ from sqlalchemy.orm import relation, sessionmaker Base = declarative_base() class Movie(Base) : - __tablename__ = "movies" + __tablename__ = "movies" id = Column(Integer, primary_key=True) title = Column(String(255), nullable=False) @@ -1326,23 +1327,23 @@ class Movie(Base) : directed_by = Column(Integer, ForeignKey("directors.id")) director = relation("Director", backref="movies", lazy=False) - def __init__(self, title=None, year=None) : + def __init__(self, title=None, year=None) : self.title = title self.year = year - def __repr__(self) : + def __repr__(self) : return "Movie(%r, %r, %r)" % (self.title, self.year, self.director) class Director(Base) : - __tablename__ = "directors" + __tablename__ = "directors" id = Column(Integer, primary_key=True) name = Column(String(50), nullable=False, unique=True) - def __init__(self, name=None) : + def __init__(self, name=None) : self.name = name - def __repr__(self) : + def __repr__(self) : return "Director(%r)" % (self.name) Base.metadata.create_all(create_engine("dbms://user:pwd@host/dbname")) @@ -1422,7 +1423,7 @@ Python2 的模块名叫 Tkinter,到 Python3 模块名改为 tkinter from Tkinter import * -if __name__ == "__main__" : +if __name__ == "__main__" : root = Tk() label = Label(root, text="Hello, world") label.pack() @@ -1456,7 +1457,7 @@ class App(wx.App) : self.SetTopWindow(self.frame) return True -if __name__ == "__main__" : +if __name__ == "__main__" : app = App() app.MainLoop() @@ -1485,7 +1486,7 @@ pygtk.require("2.0") import gtk class HelloWorld : - def __init__(self) : + def __init__(self) : self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.connect("delete_event", self.delete_event) self.window.connect("destroy", self.destroy) @@ -1512,7 +1513,7 @@ class HelloWorld : def destroy(self, widget, data=None) : gtk.main_quit() -if __name__ == "__main__" : +if __name__ == "__main__" : hello = HelloWorld() hello.main() @@ -1528,8 +1529,8 @@ Home:[https://live.gnome.org/PyGObject] from gi.repository import Gtk class MyWindow(Gtk.Window): - def __init__(self): - Gtk.Window.__init__(self, title="Hello World") + 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) @@ -1561,7 +1562,7 @@ Links:[https://en.wikipedia.org/wiki/PyQt Wikipedia] [https://zh.wikipedia.org import sys from PyQt4.QtGui import * -if __name__ == "__main__" : +if __name__ == "__main__" : app = QApplication(sys.argv) window = QWidget() From 496dfe4c1899a7de5b62db5fa3a4bec44f7807fe Mon Sep 17 00:00:00 2001 From: programthink Date: Fri, 27 Apr 2018 22:41:11 +0800 Subject: [PATCH 43/62] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E8=8B=A5=E5=B9=B2?= =?UTF-8?q?=E5=BA=93=E7=9A=84=20home=20=E7=BD=91=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/python.wiki | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/python.wiki b/libs/python.wiki index ae59560..a4703d7 100644 --- a/libs/python.wiki +++ b/libs/python.wiki @@ -629,7 +629,7 @@ if __name__ == "__main__" :

Tornado

-Home:[http://www.tornadoweb.org/en/stable/] +Home:[http://www.tornadoweb.org/] Links:[https://zh.wikipedia.org/wiki/Tornado 维基百科] @@ -1669,7 +1669,7 @@ Home:[http://code.enthought.com/chaco/]

Plotly

-Home:[https://plot.ly/d3-js-for-python-and-pandas-charts/] +Home:[https://plot.ly/] plotly是现代平台的敏捷商业智能和数据科学库,它作为一款开源的绘图库,可以应用于Python、R、MATLAB、Excel、JavaScript和jupyter等多种语言 @@ -1717,7 +1717,7 @@ Home:[https://github.com/google/keyczar]

passlib

-Home:[https://passlib.readthedocs.io/en/stable/index.html] +Home:[https://bitbucket.org/ecollins/passlib/] passlib是一个久经考验的非常成熟的跨平台的散列函数库,它所提供的功能包括随机盐密码的生成与验证,两步验证等。 @@ -1892,7 +1892,7 @@ Home:[http://lxml.de/]

beautifulsoup

-Home:[https://www.crummy.com/software/BeautifulSoup/bs4/doc/] +Home:[https://www.crummy.com/software/BeautifulSoup/] Links:[https://zh.wikipedia.org/zh-cn/Beautiful_Soup 维基百科] From 15a95bed36fff8df2b5da4304cc421e523ed1206 Mon Sep 17 00:00:00 2001 From: programthink Date: Fri, 27 Apr 2018 22:44:20 +0800 Subject: [PATCH 44/62] =?UTF-8?q?=E8=B0=83=E6=95=B4=E2=80=9D=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E7=B3=BB=E7=BB=9F=E2=80=9C=E4=B8=8B=E7=BA=A7=E5=88=86?= =?UTF-8?q?=E7=B1=BB=E7=9A=84=E9=A1=BA=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/python.wiki | 94 ++++++++++++++++++++++++------------------------ 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/libs/python.wiki b/libs/python.wiki index a4703d7..746b584 100644 --- a/libs/python.wiki +++ b/libs/python.wiki @@ -378,53 +378,7 @@ if pid == 0 : # 子进程 用于进程信号处理的标准库(主要用于 Linux & UNIX 系统)。 -== 3.5 Linux & Unix 系统相关 == - -

syslog

- -【标准库】 - -通过它可以很方便地跟 POSIX 的 syslog 服务进行交互。 - -== 3.6 Windows 系统相关 == - -

PyWin32

- -Home:[http://python.net/crew/mhammond/win32/] - -这个第三方库封装了 Windows API 及 COM API。通过它可以方便地用 Python 进行 Windows 编程(调用 COM 组件、编写 Windows 服务、等)。 - -== 3.7 程序打包 == - -

PyInstaller

- -Home:[http://www.pyinstaller.org/] - -PyInstaller 可以把你的 Python 代码制作成独立运行的程序(不依赖 Python 环境就可以运行)。 - -该工具支持多种操作系统,包括:Windows、Linux、Mac OS X、Solaris、AIX、等。 - -

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] - -这套工具可以帮助你进行第三方库的管理(下载、编译、安装、升级、卸载) - -== 3.8 系统管理 == +== 3.5 获取系统信息 ==

sys

@@ -469,6 +423,52 @@ psutil.cpu_freq() # 获取 CPU 频率 psutil.virtual_memory() # 获取内存信息 +== 3.6 Linux & Unix 系统相关 == + +

syslog

+ +【标准库】 + +通过它可以很方便地跟 POSIX 的 syslog 服务进行交互。 + +== 3.7 Windows 系统相关 == + +

PyWin32

+ +Home:[http://python.net/crew/mhammond/win32/] + +这个第三方库封装了 Windows API 及 COM API。通过它可以方便地用 Python 进行 Windows 编程(调用 COM 组件、编写 Windows 服务、等)。 + +== 3.8 程序打包 == + +

PyInstaller

+ +Home:[http://www.pyinstaller.org/] + +PyInstaller 可以把你的 Python 代码制作成独立运行的程序(不依赖 Python 环境就可以运行)。 + +该工具支持多种操作系统,包括:Windows、Linux、Mac OS X、Solaris、AIX、等。 + +

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 = From ee28561782845c2e240408a3cdfcc8f6ac71feb8 Mon Sep 17 00:00:00 2001 From: programthink Date: Fri, 27 Apr 2018 22:54:31 +0800 Subject: [PATCH 45/62] =?UTF-8?q?=E5=AE=8C=E5=96=84=20yagmail=20=E7=A4=BA?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/python.wiki | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/python.wiki b/libs/python.wiki index 746b584..b1e75c0 100644 --- a/libs/python.wiki +++ b/libs/python.wiki @@ -870,7 +870,7 @@ Home:[https://github.com/kootenpv/yagmail] import yagmail -yag = yagmail.SMTP() +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) From d5c6f40db76f360f52c7c25e9287b3cb75f796ad Mon Sep 17 00:00:00 2001 From: programthink Date: Fri, 27 Apr 2018 23:03:35 +0800 Subject: [PATCH 46/62] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=87=A0=E4=B8=AA?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=BA=93=E7=9A=84=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/python.wiki | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/libs/python.wiki b/libs/python.wiki index b1e75c0..ef1b208 100644 --- a/libs/python.wiki +++ b/libs/python.wiki @@ -612,7 +612,7 @@ Home:[http://flask.pocoo.org/] Links:[https://zh.wikipedia.org/wiki/Flask 维基百科] -轻量级Web应用框架。基于Werkzeug WSGI工具箱和Jinja2 模板引擎。 +轻量级 Web 应用框架。基于 Werkzeug WSGI 工具箱和 Jinja2 模板引擎。 代码示例——Hello world @@ -633,7 +633,7 @@ Home:[http://www.tornadoweb.org/] Links:[https://zh.wikipedia.org/wiki/Tornado 维基百科] -同样也是轻量级的Web框架,类似Web.py,但是异步非阻塞IO的处理方式使其拥有较为出色的抗负载能力。 +同样也是轻量级的 Web 框架,类似 Web.py。提供异步非阻塞 IO 的处理方式使其拥有较为出色的抗负载能力。 == 4.4 Web前端 & JS整合 == @@ -710,7 +710,7 @@ Home:[https://github.com/google/pywebsocket] Home:[http://www.seleniumhq.org/] -selenium是一个非常优秀的用于爬虫、Web自动化测试测试的框架。 +selenium 是一个非常优秀的框架,用于爬虫和 Web 自动化测试。 代码示例——模拟登录 @@ -729,7 +729,9 @@ Home:[https://scrapy.org/] Links:[https://en.wikipedia.org/wiki/Scrapy Wikipedia] -Scrapy是一个为了爬取网站数据,提取结构性数据而编写的应用框架。 可以应用在包括数据挖掘,信息处理或存储历史数据等一系列的程序中。 +Scrapy 是一个为了爬取网站数据,提取结构性数据而编写的应用框架。 + +可以应用在包括数据挖掘,信息处理或存储历史数据等一系列的程序中。 ---- @@ -900,7 +902,7 @@ Home:[https://github.com/eternnoir/pyTelegramBotAPI] Home:[https://github.com/LonamiWebs/Telethon] -纯 Python 3 的 [https://telegram.org/ Telegram] 客户端封装。 +纯 Python3 的 [https://telegram.org/ Telegram] 客户端封装。 === 5.3.6 远程控制 === @@ -944,7 +946,9 @@ Home:[https://github.com/citronneur/rdpy] Home:[http://www.paramiko.org/] -paramiko是用python语言写的一个模块,遵循SSH2协议,支持以加密和认证的方式,进行远程服务器的连接。除了SSH协议之外,paramiko还支持SFTP。 +paramiko 是用 python 语言写的一个模块,遵循SSH2协议,支持以加密和认证的方式,进行远程服务器的连接。 + +除了 SSH 协议之外,paramiko 还支持SFTP。 代码示例 @@ -1671,7 +1675,9 @@ Home:[http://code.enthought.com/chaco/] Home:[https://plot.ly/] -plotly是现代平台的敏捷商业智能和数据科学库,它作为一款开源的绘图库,可以应用于Python、R、MATLAB、Excel、JavaScript和jupyter等多种语言 +plotly 是现代平台的敏捷商业智能和数据科学库。 + +它作为一款开源的绘图库,可以应用于 Python、R、MATLAB、Excel、JavaScript、jupyter 等多种语言。 ---- @@ -1719,7 +1725,7 @@ Home:[https://github.com/google/keyczar] Home:[https://bitbucket.org/ecollins/passlib/] -passlib是一个久经考验的非常成熟的跨平台的散列函数库,它所提供的功能包括随机盐密码的生成与验证,两步验证等。 +passlib 是一个久经考验的非常成熟的跨平台的散列函数库,它所提供的功能包括随机盐密码的生成与验证,两步验证等。 代码示例——验证随机盐密码 @@ -1896,7 +1902,9 @@ Home:[https://www.crummy.com/software/BeautifulSoup/] Links:[https://zh.wikipedia.org/zh-cn/Beautiful_Soup 维基百科] -Beautiful Soup 是一个可以从HTML 或XML 文件中提取数据的Python 库,爬虫利器,通常与requests或者selenium配合。 +Beautiful Soup 可以从 HTML 或 XML 文件中提取数据。 + +它是写”爬虫“的利器,通常与 requests 或 selenium 配合。 == 9.4 PDF == From 81943cd673508d4b04d4352f498028287dd992f0 Mon Sep 17 00:00:00 2001 From: programthink Date: Fri, 27 Apr 2018 23:26:15 +0800 Subject: [PATCH 47/62] =?UTF-8?q?=E5=AE=8C=E5=96=84=20psutil=20=E7=9A=84?= =?UTF-8?q?=E6=8F=8F=E8=BF=B0=E5=92=8C=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/python.wiki | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/libs/python.wiki b/libs/python.wiki index ef1b208..4ecc184 100644 --- a/libs/python.wiki +++ b/libs/python.wiki @@ -412,7 +412,9 @@ platform.architecture() # 获取操作系统的架构,例如:("32bit", "Win Home:[https://github.com/giampaolo/psutil] -psutil(Python system and process utilities)是一个跨平台的进程管理和系统工具的python库,可以处理系统CPU,memory,disks,network等信息。主要用于系统资源的监控,分析,以及对进程进行一定的管理。 +psutil(Python system and process utilities)是一个跨平台的进程管理和系统工具库,可以处理”CPU、内存、磁盘、网络、用户“等信息。 + +主要用于系统资源的监控,分析,以及对进程进行一定的管理。 代码示例 @@ -420,7 +422,20 @@ 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.6 Linux & Unix 系统相关 == From 53ae70d5fd0b3d15a2a3384660d77e766b2f0371 Mon Sep 17 00:00:00 2001 From: programthink Date: Sat, 4 Aug 2018 19:56:14 +0800 Subject: [PATCH 48/62] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20cpr?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/cpp.wiki | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/libs/cpp.wiki b/libs/cpp.wiki index 8ad9411..3054f20 100644 --- a/libs/cpp.wiki +++ b/libs/cpp.wiki @@ -2517,6 +2517,28 @@ Docs:[http://pocoproject.org/docs/package-Net.HTTPClient.html] POCO 前面已经介绍过。它提供了 HTTP Client 的封装类。 +

cpr

+ +Home:[https://github.com/whoshuu/cpr] + +类似 Python 的 [http://docs.python-requests.org/ Requests 库],以【优雅的语法】实现 HTTP 请求。 + +代码示例——HTTP GET + +#include + +int main() +{ + auto r = cpr::Get(cpr::Url{"https://api.github.com/repos/whoshuu/cpr/contributors"}, + cpr::Authentication{"user", "pass"}, + cpr::Parameters{{"anon", "true"}, {"key", "value"}}); + r.status_code; // 200 + r.header["content-type"]; // application/json; charset=utf-8 + r.text; // JSON text string + return 0; +} + + == 10.3 浏览器引擎 ==

WebKit

From e41f440b31e25e32faee7250a107b47db8942802 Mon Sep 17 00:00:00 2001 From: programthink Date: Sat, 4 Aug 2018 20:23:20 +0800 Subject: [PATCH 49/62] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20docopt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/cpp.wiki | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/libs/cpp.wiki b/libs/cpp.wiki index 3054f20..2bef0f4 100644 --- a/libs/cpp.wiki +++ b/libs/cpp.wiki @@ -1388,6 +1388,57 @@ Boost 前面已经介绍过。这是 Boost 的其中一个子库,提供了“ 它的功能很丰富,但是比较重型。 +

docopt

+ +Home:[https://github.com/docopt/docopt.cpp] + +这是一个很有创意的库,提供了一种【全新】的方式来处理命令行参数。 + +你只需定义好命令行的帮助文本(usage),该库会根据 usage 文本自动分析出命令行参数的定义。 + +也就是说:用了这个库,就无需再写一大堆 parse 命令行参数的代码 :) + +代码示例 + +#include +#include + +static const char USAGE[] = +R"(Naval Fate. + + Usage: + naval_fate ship new ... + naval_fate ship move [--speed=] + naval_fate ship shoot + naval_fate mine (set|remove) [--moored | --drifting] + naval_fate (-h | --help) + naval_fate --version + + Options: + -h --help Show this screen. + --version Show version. + --speed= Speed in knots [default: 10]. + --moored Moored (anchored) mine. + --drifting Drifting mine. +)"; + +int main(int argc, const char* argv[]) +{ + std::map args + = docopt::docopt(USAGE, + { argv + 1, argv + argc }, + true, // 是否显示帮助 + "Naval Fate 2.0"); // 版本号 + + for(auto const& arg : args) + { + std::cout << arg.first << arg.second << std::endl; + } + +return 0; +} + + == 7.2 文本终端 ==

ncurses

From 1aab23863384ead7e4c2a8ed44d628bc1b0bb1e0 Mon Sep 17 00:00:00 2001 From: programthink Date: Sat, 4 Aug 2018 20:57:24 +0800 Subject: [PATCH 50/62] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20simple=5Fmatch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/cpp.wiki | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/libs/cpp.wiki b/libs/cpp.wiki index 2bef0f4..fb32af5 100644 --- a/libs/cpp.wiki +++ b/libs/cpp.wiki @@ -753,6 +753,35 @@ vector v; for_each(v.begin(), v.end(), cout << boost::lambda::_1 << "\n"); +

simple_match

+ +Home:[https://github.com/jbandela/simple_match] + +这个库是为了提供类似 Rust 语言中的 match 语法。 + +(不懂 Rust 的同学,可以把 match 语法视作增强版的 switch/case) + +代码示例 + +#include +#include +using namespace simple_match; +using namespace simple_match::placeholders; + +int x = 0; +while (true) +{ + std::cin >> x; + match(x, + 1, []() { std::cout << "one\n"; }, + 2, []() { std::cout << "two\n"; }, + _x < 10, [](auto&& n) { std::cout << n << " is less than 10\n"; }, + 10 < _x < 20, [](auto&& n) { std::cout << n << " is between 10 and 20 exclusive\n"; }, + _, []() { std::cout << "NOT match\n"; } + ); +} + + == 3.4 元编程(Metaprogramming) == (不知道何为“元编程”,可以先看[https://zh.wikipedia.org/wiki/%E5%85%83%E7%BC%96%E7%A8%8B 维基百科]) From 490156aaa53e7769694b5cd4cede737ef8065ece Mon Sep 17 00:00:00 2001 From: programthink Date: Sat, 4 Aug 2018 21:08:10 +0800 Subject: [PATCH 51/62] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20Poppler?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/cpp.wiki | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libs/cpp.wiki b/libs/cpp.wiki index fb32af5..0103134 100644 --- a/libs/cpp.wiki +++ b/libs/cpp.wiki @@ -3073,6 +3073,18 @@ Home:[http://podofo.sourceforge.net/] 它既支持 PDF 文件的生成,也支持 PDF 内容的提取。它同时还提供[http://podofo.sourceforge.net/tools.html 一堆命令行的小工具],用来操作 PDF 文件。 +

Poppler

+ +Home:[https://poppler.freedesktop.org/] + +Links:[https://en.wikipedia.org/wiki/Poppler_%28software%29 Wikipedia] + +派生自 Xpdf 3.0 的开源库,用于渲染 PDF 的内容。很多开源的 PDF 阅读软件用到它。 + +在开源界,它第一个【完整】实现了 ISO 32000-1(PDF 的 ISO 标准)。 + +它内置了若干命令行工具(poppler-utils),可以用来进行 PDF 的内容提取和格式转换。 +

LibHaru

Home:[http://libharu.org/] From 9b71c58132fab40f4de0719e9f17c7b913466e2b Mon Sep 17 00:00:00 2001 From: programthink Date: Sat, 4 Aug 2018 21:57:56 +0800 Subject: [PATCH 52/62] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20Scintilla?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/cpp.wiki | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libs/cpp.wiki b/libs/cpp.wiki index 0103134..e4a6bd2 100644 --- a/libs/cpp.wiki +++ b/libs/cpp.wiki @@ -1330,6 +1330,18 @@ Home:[http://wxmathplot.sourceforge.net/] 看名称就知道它是跟 wxWidgets 搭配的。效果图参见“[http://wxmathplot.sourceforge.net/screenshot.shtml 这里]” +== 6.3 文本编辑 == + +

Scintilla

+ +Home:[https://scintilla.org/] + +Links:[https://en.wikipedia.org/wiki/Scintilla_(software) Wikipedia] + +功能【超强】的文本编辑组件,支持:词法高亮、代码折叠、自动补全、动态提示......(基本上你能想到的,它都已经有了) + +不光功能齐全,还支持各种主流的操作系统平台。很多编辑器/IDE 用到它。 + ---- = 7 文本用户界面(TUI) = From 143c3755f1d398e04147a33666d661e19a9d610c Mon Sep 17 00:00:00 2001 From: programthink Date: Sun, 5 Aug 2018 17:31:25 +0800 Subject: [PATCH 53/62] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20Cython?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/cpp.wiki | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libs/cpp.wiki b/libs/cpp.wiki index e4a6bd2..58a62a1 100644 --- a/libs/cpp.wiki +++ b/libs/cpp.wiki @@ -3650,6 +3650,16 @@ BOOST_PYTHON_MODULE(hello_ext) // print(hello_ext.greet()) +

Cython

+ +Home:[http://cython.org/] + +Links:[https://en.wikipedia.org/wiki/Cython Wikipedia] + +Cython 提供了一种机制(编译器)编译 Python 代码为【原生代码】。编译后的原生代码是个 Python 的 module(扩展名是 pyd 或 so),可以在常规的 Python 环境中用 import 语句加载。如此一来,既得到了类似 C/C++ 的高性能,又保留了 Python 语法的简介性。 + +另外,它也提供了把 C/C++ 代码编译为 Python 模块的机制。 + ---- = 18 (其它) = From 03120d5d4ec8c6b4196809b95cedfedff28be5fc Mon Sep 17 00:00:00 2001 From: programthink Date: Sun, 5 Aug 2018 18:05:07 +0800 Subject: [PATCH 54/62] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20V8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/cpp.wiki | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/libs/cpp.wiki b/libs/cpp.wiki index 58a62a1..3efc90e 100644 --- a/libs/cpp.wiki +++ b/libs/cpp.wiki @@ -3660,6 +3660,72 @@ Cython 提供了一种机制(编译器)编译 Python 代码为【原生代 另外,它也提供了把 C/C++ 代码编译为 Python 模块的机制。 +=== 17.2.2 整合 JavaScript 语言 === + +

V8

+ +Home:[https://github.com/v8/v8] + +Links:[https://en.wikipedia.org/wiki/Chrome_V8 Wikipedia] + +这就是大名鼎鼎的 V8 引擎,Google 公司开发,C++ 编写,被用于 Chrome 浏览器。 + +既然用于 Chrome 浏览器,显然【完整地】支持了 JS 语言的规范(ECMA-262)。 + +它既可以独立运行,也可以嵌入到 C++ 程序中。 + +代码示例——Hello world + +#include +#include +#include +#include +#include + +int main(int argc, char* argv[]) +{ + // Initialize V8. + v8::V8::InitializeICUDefaultLocation(argv[0]); + v8::V8::InitializeExternalStartupData(argv[0]); + std::unique_ptr platform = v8::platform::NewDefaultPlatform(); + v8::V8::InitializePlatform(platform.get()); + v8::V8::Initialize(); + + // Create a new Isolate and make it the current one. + v8::Isolate::CreateParams create_params; + create_params.array_buffer_allocator = v8::ArrayBuffer::Allocator::NewDefaultAllocator(); + v8::Isolate* isolate = v8::Isolate::New(create_params); + + { + v8::Isolate::Scope isolate_scope(isolate); + // Create a stack-allocated handle scope. + v8::HandleScope handle_scope(isolate); + // Create a new context. + v8::Local context = v8::Context::New(isolate); + // Enter the context for compiling and running the hello world script. + v8::Context::Scope context_scope(context); + // Create a string containing the JavaScript source code. + v8::Local source = + v8::String::NewFromUtf8(isolate, "'Hello World!'", + v8::NewStringType::kNormal).ToLocalChecked(); + // Compile the source code. + v8::Local script = v8::Script::Compile(context, source).ToLocalChecked(); + // Run the script to get the result. + v8::Local result = script->Run(context).ToLocalChecked(); + // Convert the result to an UTF8 string and print it. + v8::String::Utf8Value utf8(isolate, result); + printf("%s\n", *utf8); + } + + // Dispose the isolate and tear down V8. + isolate->Dispose(); + v8::V8::Dispose(); + v8::V8::ShutdownPlatform(); + delete create_params.array_buffer_allocator; + return 0; +} + + ---- = 18 (其它) = From 5810f1337566397ec488ccf57888e6359634ee1c Mon Sep 17 00:00:00 2001 From: programthink Date: Sun, 5 Aug 2018 18:51:55 +0800 Subject: [PATCH 55/62] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20nbind?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/cpp.wiki | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/libs/cpp.wiki b/libs/cpp.wiki index 3efc90e..723d5c9 100644 --- a/libs/cpp.wiki +++ b/libs/cpp.wiki @@ -3726,6 +3726,57 @@ int main(int argc, char* argv[]) } +

nbind

+ +Home:[https://github.com/charto/nbind] + +把 C++ 代码编译为 JS 的 package。编译方式支持“原生二进制”或“asm.js”。 + +编译需要依赖 Node.js,运行环境支持 Node.js 或浏览器。 + +代码示例——C++ 代码 + +#include +#include + +struct Greeter +{ + static void sayHello(std::string name) + { + std::cout << "Hello, " << name << "\n"; + } +}; + +// 建立绑定 +#include + +NBIND_CLASS(Greeter) +{ + method(sayHello); +} + + +代码示例——node.js 环境调用代码 + +var nbind = require("nbind"); +var lib = nbind.init().lib; +lib.Greeter.sayHello("you"); + + +代码示例——浏览器环境调用代码 + + + + + ---- = 18 (其它) = From 315f1f0af8653695468a17c626081de7fbf20764 Mon Sep 17 00:00:00 2001 From: programthink Date: Fri, 10 Aug 2018 16:53:04 +0800 Subject: [PATCH 56/62] =?UTF-8?q?=E7=A4=BA=E4=BE=8B=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E4=B8=AD=E8=A1=8C=E9=A6=96=20#=20=E5=AD=97=E7=AC=A6=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=20HTML=20=E8=BD=AC=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/python.wiki | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/libs/python.wiki b/libs/python.wiki index 4ecc184..73581bc 100644 --- a/libs/python.wiki +++ b/libs/python.wiki @@ -769,7 +769,7 @@ Links:[https://en.wikipedia.org/wiki/Scapy Wikipedia] # 传统的 ping 扫描(网络层) ans,unans = sr(IP(dst="192.168.1.1-254")/ICMP()) -# 局域网内的 ARP 扫描(链路层) +# 局域网内的 ARP 扫描(链路层) ans,unans = srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst="192.168.1.0/24"), timeout=2) @@ -1796,14 +1796,14 @@ JSON 格式源自 JavaScript,如今在 Web 开发中广为应用。 import json json.dumps(["foo", {"bar": ("baz", None, 1.0, 2)}]) -# JSON 编码 -# 得到如下【字符串】 -# """["foo", {"bar": ["baz", null, 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]}] +# JSON 解码 +# 得到如下【对象】 +# [u"foo", {u"bar": [u"baz", None, 1.0, 2]}] === 9.1.3 YAML === @@ -2119,11 +2119,11 @@ Home:[https://github.com/xflr6/graphviz] 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') @@ -2217,7 +2217,7 @@ c = [] for i in range(len(a)) : c.append(a[i] + b[i]) -# 以下是 NumPy 的写法,简洁且速度飞快 +# 以下是 NumPy 的写法,简洁且速度飞快 import numpy as np a = np.arange(10000000) b = np.arange(10000000) From 446858bfbe61290e7d37ccdd6f982ddf401add15 Mon Sep 17 00:00:00 2001 From: programthink Date: Fri, 10 Aug 2018 17:16:31 +0800 Subject: [PATCH 57/62] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20keyboard?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/python.wiki | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/libs/python.wiki b/libs/python.wiki index 73581bc..fa715d4 100644 --- a/libs/python.wiki +++ b/libs/python.wiki @@ -378,7 +378,35 @@ if pid == 0 : # 子进程 用于进程信号处理的标准库(主要用于 Linux & UNIX 系统)。 -== 3.5 获取系统信息 == +== 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") + +# 记录按键,直到用户按了 ESC;然后以3倍速重放刚才记录的按键。 +recorded = keyboard.record(until="esc") +keyboard.play(recorded, speed_factor=3) + + +== 3.6 获取系统信息 ==

sys

@@ -438,7 +466,7 @@ p.cwd() # 进程的当前目录 p.cmdline() # 启动进程的命令行参数 -== 3.6 Linux & Unix 系统相关 == +== 3.7 Linux & Unix 系统相关 ==

syslog

@@ -446,7 +474,7 @@ p.cmdline() # 启动进程的命令行参数 通过它可以很方便地跟 POSIX 的 syslog 服务进行交互。 -== 3.7 Windows 系统相关 == +== 3.8 Windows 系统相关 ==

PyWin32

@@ -454,7 +482,7 @@ Home:[http://python.net/crew/mhammond/win32/] 这个第三方库封装了 Windows API 及 COM API。通过它可以方便地用 Python 进行 Windows 编程(调用 COM 组件、编写 Windows 服务、等)。 -== 3.8 程序打包 == +== 3.9 程序打包 ==

PyInstaller

From 34bb7d079596f44c70d3b1eef017ba45e76d5c0c Mon Sep 17 00:00:00 2001 From: programthink Date: Tue, 30 Oct 2018 23:10:19 +0800 Subject: [PATCH 58/62] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E2=80=9DWebSocket?= =?UTF-8?q?=E2=80=9C=E5=88=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/python.wiki | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libs/python.wiki b/libs/python.wiki index fa715d4..86290b2 100644 --- a/libs/python.wiki +++ b/libs/python.wiki @@ -739,16 +739,18 @@ Home:[https://github.com/jmalonzo/pywebkitgtk] PyWebKitGtk 则提供了对 WebKitGtk 的 Python 封装。 -== 4.6 (其它) == +== 4.6 WebSocket ==

pywebsocket

Home:[https://github.com/google/pywebsocket] -这是 Google 提供的 [https://zh.wikipedia.org/wiki/WebSocket WebSocket] 服务端。 +这是 Google 提供的 [https://zh.wikipedia.org/wiki/WebSocket WebSocket]【服务端】。 该项目包含一个可独立运行的 server 以及一个 Apache 扩展模块(mod_pywebsocket)。 +== 4.7 (其它) == +

selenium

Home:[http://www.seleniumhq.org/] From 73c27911a3c243ebd03a31d33b2aecf61113c43f Mon Sep 17 00:00:00 2001 From: programthink Date: Tue, 30 Oct 2018 23:27:19 +0800 Subject: [PATCH 59/62] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20ws4py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/python.wiki | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libs/python.wiki b/libs/python.wiki index 86290b2..d83820e 100644 --- a/libs/python.wiki +++ b/libs/python.wiki @@ -741,14 +741,23 @@ PyWebKitGtk 则提供了对 WebKitGtk 的 Python 封装。 == 4.6 WebSocket == +(关于 WebSocket 的介绍,可以参见维基百科的“[https://zh.wikipedia.org/wiki/WebSocket 这个链接]”)

pywebsocket

Home:[https://github.com/google/pywebsocket] -这是 Google 提供的 [https://zh.wikipedia.org/wiki/WebSocket WebSocket]【服务端】。 +这是 Google 提供的 WebSocket【服务端】。 该项目包含一个可独立运行的 server 以及一个 Apache 扩展模块(mod_pywebsocket)。 +

ws4py

+ +Home:[https://github.com/Lawouach/WebSocket-for-Python] + +此项目同时提供了 WebSocket 的“服务端 & 客户端”;并同时支持 Python2 和 Python3。 + +其【服务端】可以跟“CherryPy、gevent、wsgiref、asyncio”整合;其【客户端】可以跟“Tornado、gevent”整合。 + == 4.7 (其它) ==

selenium

From bf30db21fb845086432e9d989ea5cc818f9b4ede Mon Sep 17 00:00:00 2001 From: programthink Date: Tue, 30 Oct 2018 23:46:23 +0800 Subject: [PATCH 60/62] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20AutobahnPython?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/python.wiki | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/libs/python.wiki b/libs/python.wiki index d83820e..e573f04 100644 --- a/libs/python.wiki +++ b/libs/python.wiki @@ -750,11 +750,45 @@ Home:[https://github.com/google/pywebsocket] 该项目包含一个可独立运行的 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 协议,它还完整实现了 WAMP(Web 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。 +此项目同时提供了 WebSocket 的“服务端 & 客户端”;并同时兼容 Python2 和 Python3。 其【服务端】可以跟“CherryPy、gevent、wsgiref、asyncio”整合;其【客户端】可以跟“Tornado、gevent”整合。 From c9ef0a0dfc06716b7ac43d71e0d7cf33c0212a4d Mon Sep 17 00:00:00 2001 From: programthink Date: Tue, 30 Oct 2018 23:59:30 +0800 Subject: [PATCH 61/62] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20sh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/python.wiki | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libs/python.wiki b/libs/python.wiki index e573f04..6d00d34 100644 --- a/libs/python.wiki +++ b/libs/python.wiki @@ -349,6 +349,18 @@ if __name__ == "__main__" : Process(target=f, args=(lock, num)).start() +

sh

+ +Home:[https://github.com/amoffat/sh] + +这个项目可以用来取代标准库中的 subprocess;同时兼容 Python2 和 Python3。 + +代码示例 + +from sh import ifconfig +print(ifconfig("wlan0")) + + == 3.4 本地进程间通信(IPC) ==

mmap

From 23adccf2dc6f2d4ca74abc136e1a94777c456276 Mon Sep 17 00:00:00 2001 From: programthink Date: Wed, 31 Oct 2018 00:13:00 +0800 Subject: [PATCH 62/62] =?UTF-8?q?=E5=AE=8C=E5=96=84=20sh=20=E7=9A=84?= =?UTF-8?q?=E6=8F=8F=E8=BF=B0=E5=92=8C=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/python.wiki | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/libs/python.wiki b/libs/python.wiki index 6d00d34..5dd27e0 100644 --- a/libs/python.wiki +++ b/libs/python.wiki @@ -355,12 +355,29 @@ 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