你應該了解的Python模塊

jopen 11年前發布 | 18K 次閱讀 Python Python開發

最好的Python模塊集合。Python是美麗的。因此,利用這些模塊保持你的代碼清潔,可維護。

Modules

  • Docopt. Forget optparse and argparse, and build beautiful, readable and (if you need) complex command-line interfaces using docstrings. IMO the best module created in 2013.

  • Requests, or HTTP for humans, is a more pythonic approach to deal with HTTP requests. Much, much, much better than urllib2. And it has been downloaded over 5,000,000 times from PyPI for a reason :)

  • lxml is a binding for libxml2 and libxslt. If you are dealing with XML or HMTL, lxml is the best solution. Full stop.

  • Bottle is a fast, simple and lightweight WSGI micro web-framework. Build small websites and REST APIs in seconds. All the framework is just one py file that you can drop in your directory.

  • sh is a full-fledged subprocess interface for Python that allows you to call any program as if it were a function. Super handy.

  • Structlog is advanced processor for logging. It integrates with any existing logger, wrapping the Python standard library. You can build custom loggers, adding context as you go, to keep your logs consistent and readable.

  • Watchdog is cross platform Python library and shell utilities to monitor file system events. Super handy and easy to use.

  • Delorean lets you play with dates and times in a very convenient way. Set time zones, truncate to seconds, minutes, hours, or even iterate from one date to another using a specific step. Check out the doc, it contains plenty of examples.

Bonus track

  • PEW. I discovered this project only one month ago, and I felt in love. PEW is a set of tools to manage multiple virtual environments. Works flawlessly on bash, zsh, fish and powershell. Give it a try.

  • antigravity. Run a Python shell (>=2.7) and type import antigravity.

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!