【干货】50 个常用的 Python 库和示例代码
通过分析 github 上 5000 个开源 python 项目,找出了最常用的库,下表是最常用的前 50
个。括号里的数字代表其出现的次数。
序号
库
链接
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
os (2810)
sys (2563)
re (1986)
time (1478)
http://www.programcreek.com/python/index/1/os
http://www.programcreek.com/python/index/2/sys
http://www.programcreek.com/python/index/3/re
http://www.programcreek.com/python/index/4/time
logging (1080)
http://www.programcreek.com/python/index/5/logging
datetime (1032)
http://www.programcreek.com/python/index/6/datetime
unittest (960)
random (891)
urllib (776)
os.path (723)
string (659)
math (560)
socket (556)
types (548)
http://www.programcreek.com/python/index/7/unittest
http://www.programcreek.com/python/index/8/random
http://www.programcreek.com/python/index/9/urllib
http://www.programcreek.com/python/index/10/os.path
http://www.programcreek.com/python/index/11/string
http://www.programcreek.com/python/index/12/math
http://www.programcreek.com/python/index/13/socket
http://www.programcreek.com/python/index/14/types
subprocess (529)
http://www.programcreek.com/python/index/15/subprocess
tempfile (492)
http://www.programcreek.com/python/index/16/tempfile
shutil (484)
http://www.programcreek.com/python/index/17/shutil
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
threading (475)
http://www.programcreek.com/python/index/18/threading
traceback (473)
http://www.programcreek.com/python/index/19/traceback
urllib2 (472)
http://www.programcreek.com/python/index/20/urllib2
copy (455)
cgi (425)
struct (420)
http://www.programcreek.com/python/index/21/copy
http://www.programcreek.com/python/index/22/cgi
http://www.programcreek.com/python/index/23/struct
warnings (412)
http://www.programcreek.com/python/index/24/warnings
base64 (398)
urlparse (377)
codecs (365)
itertools (328)
glob (322)
inspect (310)
operator (309)
StringIO (304)
errno (302)
http://www.programcreek.com/python/index/25/base64
http://www.programcreek.com/python/index/26/urlparse
http://www.programcreek.com/python/index/27/codecs
http://www.programcreek.com/python/index/28/itertools
http://www.programcreek.com/python/index/29/glob
http://www.programcreek.com/python/index/30/inspect
http://www.programcreek.com/python/index/31/operator
http://www.programcreek.com/python/index/32/StringIO
http://www.programcreek.com/python/index/33/errno
optparse (298)
http://www.programcreek.com/python/index/34/optparse
hashlib (288)
httplib (271)
json (269)
pickle (251)
signal (248)
getopt (236)
http://www.programcreek.com/python/index/35/hashlib
http://www.programcreek.com/python/index/36/httplib
http://www.programcreek.com/python/index/37/json
http://www.programcreek.com/python/index/38/pickle
http://www.programcreek.com/python/index/39/signal
http://www.programcreek.com/python/index/40/getopt
41
42
43
44
45
46
47
48
49
50
csv (218)
http://www.programcreek.com/python/index/41/csv
mimetypes (205)
http://www.programcreek.com/python/index/42/mimetypes
ConfigParser (202)
http://www.programcreek.com/python/index/43/ConfigParser
settings (198)
http://www.programcreek.com/python/index/44/settings
simplejson (197)
http://www.programcreek.com/python/index/45/simplejson
gtk (188)
imp (183)
pprint (178)
zipfile (174)
http://www.programcreek.com/python/index/46/gtk
http://www.programcreek.com/python/index/47/imp
http://www.programcreek.com/python/index/48/pprint
http://www.programcreek.com/python/index/49/zipfile
textwrap (170)
http://www.programcreek.com/python/index/50/textwrap