Python 常用的标准库以及第三方库有哪些 Python 常用的标准库以及第三方库有哪些

Python\u5e38\u7528\u7684\u6807\u51c6\u5e93\u4ee5\u53ca\u7b2c\u4e09\u65b9\u5e93\u6709\u54ea\u4e9b\uff1f

\u63a8\u83505\u4e2a\u5e38\u7528\u7684Python\u6807\u51c6\u5e93\uff1a
1\u3001os\uff1a\u63d0\u4f9b\u4e86\u4e0d\u5c11\u4e0e\u64cd\u4f5c\u7cfb\u7edf\u76f8\u5173\u8054\u7684\u51fd\u6570\u5e93
os\u5305\u662fPython\u4e0e\u64cd\u4f5c\u7cfb\u7edf\u7684\u63a5\u53e3\u3002\u6211\u4eec\u53ef\u4ee5\u7528os\u5305\u6765\u5b9e\u73b0\u64cd\u4f5c\u7cfb\u7edf\u7684\u8bb8\u591a\u529f\u80fd\uff0c\u6bd4\u5982\u7ba1\u7406\u7cfb\u7edf\u8fdb\u7a0b\uff0c\u6539\u53d8\u5f53\u524d\u8def\u5f84\uff0c\u6539\u53d8\u6587\u4ef6\u6743\u9650\u7b49\u3002\u4f46\u8981\u6ce8\u610f\uff0cos\u5305\u662f\u5efa\u7acb\u5728\u64cd\u4f5c\u7cfb\u7edf\u7684\u5e73\u53f0\u4e0a\u7684\uff0c\u8bb8\u591a\u529f\u80fd\u5728Windows\u7cfb\u7edf\u4e0a\u662f\u65e0\u6cd5\u5b9e\u73b0\u7684\u3002\u53e6\u5916\uff0c\u5728\u4f7f\u7528os\u5305\u4e2d\uff0c\u8981\u6ce8\u610f\u5176\u4e2d\u7684\u6709\u4e9b\u529f\u80fd\u5df2\u7ecf\u88ab\u5176\u4ed6\u7684\u5305\u53d6\u4ee3\u3002
\u6211\u4eec\u901a\u8fc7\u6587\u4ef6\u7cfb\u7edf\u6765\u7ba1\u7406\u78c1\u76d8\u4e0a\u50a8\u5b58\u7684\u6587\u4ef6\u3002\u67e5\u627e\u3001\u5220\u9664\u3001\u590d\u5236\u6587\u4ef6\u4ee5\u53ca\u5217\u51fa\u6587\u4ef6\u5217\u8868\u7b49\u90fd\u662f\u5e38\u89c1\u7684\u6587\u4ef6\u64cd\u4f5c\u3002\u8fd9\u4e9b\u529f\u80fd\u901a\u5e38\u53ef\u4ee5\u5728\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u770b\u5230\uff0c\u4f46\u73b0\u5728\u53ef\u4ee5\u901a\u8fc7Python\u6807\u51c6\u5e93\u4e2d\u7684glob\u5305\u3001shutil\u5305\u3001os.path\u5305\u4ee5\u53caos\u5305\u7684\u4e00\u4e9b\u51fd\u6570\u7b49\uff0c\u5728Python\u5185\u90e8\u5b9e\u73b0\u3002
2\u3001sys\uff1a\u901a\u5e38\u7528\u4e8e\u547d\u4ee4\u884c\u53c2\u6570\u7684\u5e93
sys\u5305\u88ab\u7528\u4e8e\u7ba1\u7406Python\u81ea\u8eab\u7684\u8fd0\u884c\u73af\u5883\u3002Python\u662f\u4e00\u4e2a\u89e3\u91ca\u5668\uff0c\u4e5f\u662f\u4e00\u4e2a\u8fd0\u884c\u5728\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u7684\u7a0b\u5e8f\u3002\u6211\u4eec\u53ef\u4ee5\u7528sys\u5305\u6765\u63a7\u5236\u8fd9\u4e00\u7a0b\u5e8f\u8fd0\u884c\u7684\u8bb8\u591a\u53c2\u6570\uff0c\u6bd4\u5982\u8bf4Python\u8fd0\u884c\u6240\u80fd\u5360\u636e\u7684\u5185\u5b58\u548cCPU\uff0cPython\u6240\u8981\u626b\u63cf\u7684\u8def\u5f84\u7b49\u3002\u53e6\u4e00\u4e2a\u91cd\u8981\u529f\u80fd\u662f\u548cPython\u81ea\u5df1\u7684\u547d\u4ee4\u884c\u4e92\u52a8\uff0c\u4ece\u547d\u4ee4\u884c\u8bfb\u53d6\u547d\u4ee4\u548c\u53c2\u6570\u3002
3\u3001random\uff1a\u7528\u4e8e\u751f\u6210\u968f\u673a\u6570\u7684\u5e93
Python\u6807\u51c6\u5e93\u4e2d\u7684random\u51fd\u6570\uff0c\u53ef\u4ee5\u751f\u6210\u968f\u673a\u6d6e\u70b9\u6570\u3001\u6574\u6570\u3001\u5b57\u7b26\u4e32\uff0c\u751a\u81f3\u5e2e\u52a9\u4f60\u968f\u673a\u9009\u62e9\u5217\u8868\u5e8f\u5217\u4e2d\u7684\u4e00\u4e2a\u5143\u7d20\uff0c\u6253\u4e71\u4e00\u7ec4\u6570\u636e\u7b49\u3002
4\u3001math\uff1a\u63d0\u4f9b\u4e86\u6570\u5b66\u5e38\u6570\u548c\u6570\u5b66\u51fd\u6570
\u6807\u51c6\u5e93\u4e2d\uff0cPython\u5b9a\u4e49\u4e86\u4e00\u4e9b\u65b0\u7684\u6570\u5b57\u7c7b\u578b\uff0c\u4ee5\u5f25\u8865\u4e4b\u524d\u7684\u6570\u5b57\u7c7b\u578b\u53ef\u80fd\u7684\u4e0d\u8db3\u3002\u6807\u51c6\u5e93\u8fd8\u5305\u542b\u4e86random\u5305\uff0c\u7528\u4e8e\u5904\u7406\u968f\u673a\u6570\u76f8\u5173\u7684\u529f\u80fd\u3002math\u5305\u8865\u5145\u4e86\u4e00\u4e9b\u91cd\u8981\u7684\u6570\u5b66\u5e38\u6570\u548c\u6570\u5b66\u51fd\u6570\uff0c\u6bd4\u5982pi\u3001\u4e09\u89d2\u51fd\u6570\u7b49\u7b49\u3002
5\u3001datetime\uff1a\u65e5\u671f\u548c\u65f6\u95f4\u7684\u64cd\u4f5c\u5e93
\u65e5\u671f\u548c\u65f6\u95f4\u7684\u7ba1\u7406\u5e76\u4e0d\u590d\u6742\uff0c\u4f46\u5bb9\u6613\u72af\u9519\u3002Python\u7684\u6807\u51c6\u5e93\u4e2d\u5bf9\u65e5\u671f\u548c\u65f6\u95f4\u7684\u7ba1\u7406\u9887\u4e3a\u5b8c\u5584\uff0c\u4f60\u4e0d\u4ec5\u53ef\u4ee5\u8fdb\u884c\u65e5\u671f\u65f6\u95f4\u7684\u67e5\u8be2\u548c\u53d8\u6362\uff0c\u8fd8\u53ef\u4ee5\u5bf9\u65e5\u671f\u65f6\u95f4\u8fdb\u884c\u8fd0\u7b97\u3002\u901a\u8fc7\u8fd9\u4e9b\u6807\u51c6\u5e93\uff0c\u8fd8\u53ef\u4ee5\u6839\u636e\u9700\u8981\u63a7\u5236\u65e5\u671f\u65f6\u95f4\u8f93\u51fa\u7684\u6587\u672c\u683c\u5f0f

\u6211\u4e5f\u6765\u51e0\u4e2a\u5427
standard libs:

itertools

functools \u5b66\u597dpython\u6709\u5fc5\u8981\u638c\u63e1\u4e0a\u9762\u8fd9\u4e24\u4e2a\u5e93\u5427\uff0c
re \u6b63\u5219
subprocess \u8c03\u7528shell\u547d\u4ee4\u7684\u795e\u5668
pdb \u8c03\u8bd5
traceback \u8c03\u8bd5
pprint \u6f02\u4eae\u7684\u8f93\u51fa
logging \u65e5\u5fd7
threading\u548cmultiprocessing \u591a\u7ebf\u7a0b
urllib/urllib2/httplib http\u5e93\uff0chttplib\u5e95\u5c42\u4e00\u70b9\uff0c\u63a8\u8350\u7b2c\u4e09\u65b9\u7684\u5e93requests
os/sys \u7cfb\u7edf\uff0c\u73af\u5883\u76f8\u5173
Queue \u961f\u5217
pickle/cPickle \u5e8f\u5217\u5316\u5de5\u5177
hashlib md5, sha\u7b49hash\u7b97\u6cd5
cvs
json/simplejson python\u7684json\u5e93\uff0c\u636eso\u4e0a\u7684\u8ba8\u8bba\u548cbenchmark\uff0csimplejson\u7684\u6027\u80fd\u8981\u9ad8\u4e8ejson
timeit \u8ba1\u7b97\u4ee3\u7801\u8fd0\u884c\u7684\u65f6\u95f4\u7b49\u7b49
cProfile python\u6027\u80fd\u6d4b\u91cf\u6a21\u5757
glob \u7c7b\u4f3c\u4e0elistfile\uff0c\u53ef\u4ee5\u7528\u6765\u67e5\u627e\u6587\u4ef6
atexit \u6709\u4e00\u4e2a\u6ce8\u518c\u51fd\u6570\uff0c\u53ef\u7528\u4e8e\u6b63\u597d\u5728\u811a\u672c\u9000\u51fa\u8fd0\u884c\u524d\u6267\u884c\u4e00\u4e9b\u4ee3\u7801
dis python \u53cd\u6c47\u7f16\uff0c\u5f53\u5bf9\u67d0\u6761\u8bed\u53e5\u4e0d\u7406\u89e3\u539f\u7406\u65f6\uff0c\u53ef\u4ee5\u7528dis.dis \u51fd\u6570\u6765\u67e5\u770b\u4ee3\u7801\u5bf9\u5e94\u7684python \u89e3\u91ca\u5668\u6307\u4ee4\u7b49\u7b49\u3002

3th libs:

paramiko ssh python \u5e93
selenium \u6d4f\u89c8\u5668\u81ea\u52a8\u5316\u6d4b\u8bd5\u5de5\u5177selenium\u7684python \u63a5\u53e3
lxml python \u89e3\u6790html,xml \u7684\u795e\u5668
mechanize Stateful programmatic web browsing

pycurl cURL library module for Python
Fabric Fabric is a Python (2.5 or higher) library and command-line tool for streamlining the use of SSH for application deployment or systems administration tasks.

xmltodict xml \u8f6c dict\uff0c\u771f\u5fc3\u597d\u7528
urllib3 \u548c requests: \u5f53\u7136\u5176\u5b9erequests\u5c31\u591f\u4e86 Requests: HTTP for Humans
flask web \u5fae\u6846\u67b6
ipdb \u8c03\u8bd5\u795e\u5668\uff0c\u540c\u65f6\u63a8\u8350ipython\uff01\u7ed3\u5408ipython\u4f7f\u7528
redis redis python\u63a5\u53e3
pymongo mongodbpython\u63a5\u53e3
PIL python\u56fe\u50cf\u5904\u7406
mako python\u6a21\u7248\u5f15\u64ce
numpy \uff0c scipy \u79d1\u5b66\u8ba1\u7b97
matplotlib \u753b\u56fe

scrapy \u722c\u866b
django/tornado/web.py/web2py/uliweb/flask/twisted/bottle/cherrypy.\u7b49\u7b49 python web\u6846\u67b6/\u670d\u52a1\u5668
sh 1.08 \u2014 sh v1.08 documentation \u7528\u6765\u8fd0\u884cshell \u6a21\u5757\u7684 \u6781\u4f73\u9009\u62e9

常用标准库:os,sys,subprocess,pickle,multiprocessing,re,time,thinter

第三方:图像处理PIL,HTML解析bs4、pyquery,xml解析lxml, 科学计算numpy,scipy
反正这些是随到随用的,要用什么就学什么

不同的工作的人使用的标准库和第三方库是不一样的。
其中内建函数肯定是都要用的,re,os,sys,time,datetime估计也都会用到,这些都是比较基础的。
其它的估计就是根据项目和功能需求来使用了。

标准库列表:https://docs.python.org/2/library/
第三方库列表:https://pypi.python.org/pypi

如果解决了您的问题请采纳!
如果未解决请继续追问!

扩展阅读:学python后到底能干什么 ... python for beginners ... python手机版下载官方 ... python模块库大全 ... python初学编程必背 ... 十大常用python库 ... python入门教程完整版 ... python常用函数大全 ... python第三方库和标准库 ...

本站交流只代表网友个人观点,与本站立场无关
欢迎反馈与建议,请联系电邮
2024© 车视网