昨晚安装Django的时候总是安装到一半就报错,而且速度很慢,问题主要是国外的源连接不稳定会中断所致。后来就想到了切换到国内源。想到可能还会有同学碰到类似的问题,特此记录分享一下

pip国内的一些镜像

公网:http://e.pypi.python.org/simple
教育网:http://pypi.tuna.tsinghua.edu.cn/simple
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
豆瓣(douban) http://pypi.douban.com/simple/
阿里云 http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
华中理工大学http://pypi.hustunique.com/simple
山东理工大学http://pypi.sdutlinux.org/simple

修改源方法:

临时使用:

可以在使用pip的时候在后面加上-i参数,指定pip源

pip install scrapy -i https://pypi.tuna.tsinghua.edu.cn/simple

指定需要安装的库requirements.txt

pip install -r "/home/admin/$APP_NAME/conf/requirements.txt" -i "http://mirrors.aliyun.com/pypi/simple" --trusted-host "mirrors.aliyun.com" && #通过阿里云镜像安装三方库

永久修改:

linux:

修改 ~/.pip/pip.conf (没有就创建一个), 内容如下:

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

windows:

直接在user目录中创建一个pip目录,如:C:Usersxxpip,新建文件pip.ini,内容如下

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

参考:https://pip.pypa.io/en/latest/configuration/

精选的Python框架,库,软件和资源的精选列表。


管理员面板

管理界面的库

  • Ajenti - 您的服务器应得的管理面板。
  • django-suit - 替代Django管理界面(仅限非商业用途)。
  • django-xadmin - 直接替换Django管理员有很多好东西。
  • flask-admin - Flask的简单且可扩展的管理界面框架。
  • flower - Celery的实时监控和Web管理员。
  • Grappelli - Django Admin-Interface的爵士皮肤。
  • Wooey - 一个为Python脚本创建自动Web UI的Django应用程序。

算法和设计模式

Python实现算法和设计模式

  • algorithms - Python中数据结构和算法的最小示例
  • PyPattyrn - 一个简单而有效的库,用于实现通用设计模式。
  • python-patterns - Python中的一组设计模式。
  • sortedcontainers - SortedList,SortedDict和SortedSet类型的快速,纯Python实现。
  • SCOOP - Python中的可扩展并发操作。

反垃圾邮件

打击垃圾邮件的图书馆

资产管理

用于管理,压缩和缩小网站资产的工具。

音频

用于操纵音频的库

  • audiolazy - 用于Python的表达式数字信号处理(DSP)包。
  • audioread - 跨库(GStreamer + Core Audio + MAD + FFmpeg)音频解码。
  • beets - 音乐库管理器和MusicBrainz标记器。
  • dejavu - 音频指纹识别和识别。
  • django-elastic-transcoder - Django + Amazon Elastic Transcoder.
  • eyeD3 - 用于处理音频文件的工具,特别是包含ID3元数据的MP3文件。
  • id3reader - 用于读取MP3元数据的Python模块。
  • m3u8 - 用于解析m3u8文件的模块。
  • mingus - 具有MIDI文件和播放支持的高级音乐理论和乐谱包。
  • mutagen - 用于处理音频元数据的Python模块。
  • pyAudioAnalysis - Python音频分析库:特征提取,分类,分段和应用程序
  • pydub - 使用简单易用的高级界面处理音频。
  • pyechonest - Python client for the Echo Nest API.
  • talkbox - 用于语音/信号处理的Python库。
  • TimeSide - 开放式网络音频处理框架。
  • tinytag - 用于读取MP3,OGG,FLAC和Wave文件的音乐元数据的库。

认证

用于实现认证方案的库

  • OAuth

    • Authomatic - 简单但功能强大的框架无关的身份验证/授权客户端。
    • django-allauth - Django的认证应用程序“正常工作”。
    • django-oauth-toolkit - 用于Django的OAuth 2好东西。
    • Flask-OAuthlib - OAuth 1.0 / a,2.0实现Flask的客户端和提供程序。
    • OAuthLib - OAuth请求签名逻辑的通用且全面的实现。
    • python-oauth2 - 一个经过全面测试的抽象界面,用于创建OAuth客户端和服务器。
    • python-social-auth - 一种易于设置的社交认证机制。
    • rauth - OAuth 1.0 / a,2.0和Ofly的Python库。
    • sanction - 一个简单的OAuth2客户端实现。
  • 其他

    • jose - JavaScript对象签名和加密草案实现。
    • PyJWT - JSON Web令牌草案01的实现。
    • python-jws - JSON Web签名草案02的实现。
    • python-jwt - 用于生成和验证JSON Web令牌的模块。

构建工具

从源代码编译软件

  • BitBake - 嵌入式Linux的类似make的构建工具。
  • buildout - 用于从多个部分创建,组装和部署应用程序的构建系统。
  • PlatformIO - 用于构建具有不同开发平台的代码的控制台工具。
  • PyBuilder - 用纯Python编写的连续构建工具。
  • SCons - 一种软件构建工具。

内置类增强功能

用于增强Python内置类的库

  • attrs - Replacement for __init__, __eq__, __repr__, etc. boilerplate in class definitions.
  • bidict - Efficient, Pythonic bidirectional map data structures and related functionality..
  • Box - Python dictionaries with advanced dot notation access.
  • dotted - A library that provides a method of accessing lists and dicts with a dotted path notation.

CMS

Content Management Systems.

  • django-cms - An Open source enterprise CMS based on the Django.
  • djedi-cms - A lightweight but yet powerful Django CMS with plugins, inline editing and performance in mind.
  • FeinCMS - One of the most advanced Content Management Systems built on Django.
  • Kotti - A high-level, Pythonic web application framework built on Pyramid.
  • Mezzanine - A powerful, consistent, and flexible content management platform.
  • Opps - A Django-based CMS for magazines, newspapers websites and portals with high-traffic.
  • Plone - A CMS built on top of the open source application server Zope.
  • Quokka - Flexible, extensible, small CMS powered by Flask and MongoDB.
  • Wagtail - A Django content management system.
  • Widgy - Last CMS framework, based on Django.

高速缓存

Libraries for caching data.

  • Beaker - A library for caching and sessions for use with web applications and stand-alone Python scripts and applications.
  • DiskCache - SQLite and file backed cache backend with faster lookups than memcached and redis.
  • django-cache-machine - Automatic caching and invalidation for Django models.
  • django-cacheops - A slick ORM cache with automatic granular event-driven invalidation.
  • django-viewlet - Render template parts with extended cache control.
  • dogpile.cache - dogpile.cache is next generation replacement for Beaker made by same authors.
  • HermesCache - Python caching library with tag-based invalidation and dogpile effect prevention.
  • johnny-cache - A caching framework for Django applications.
  • pylibmc - A Python wrapper around the libmemcached interface.

ChatOps工具

Libraries for chatbot development.

  • Errbot - The easiest and most popular chatbot to implement ChatOps.

代码分析

Tools of static analysis, linters and code quality checkers. See: awesome-static-analysis.

  • Code Analysis

    • flake8 - A wrapper around pycodestyle, pyflakes and McCabe.
    • coala - Language independent and easily extendable code analysis application.
    • code2flow - Turn your Python and JavaScript code into DOT flowcharts.
    • prospector - A tool to analyse Python code.
    • pycallgraph - A library that visualises the flow (call graph) of your Python application.
    • pylama - A code audit tool for Python and JavaScript.
    • pylint - A fully customizable source code analyzer.
  • Static Type Checkers

    • mypy - Check variable types during compile time.
    • Pyre - Performant type checking.
  • Static Type Annotations Generators

    • MonkeyType - A system for Python that generates static type annotations by collecting runtime types

命令行工具

Libraries for building command-line application.

  • Command-line Application Development

    • asciimatics - A package to create full-screen text UIs (from interactive forms to ASCII animations).
    • bashplotlib - Making basic plots in the terminal.
    • cement - CLI Application Framework for Python.
    • click - A package for creating beautiful command line interfaces in a composable way.
    • cliff - A framework for creating command-line programs with multi-level commands.
    • clint - Python Command-line Application Tools.
    • colorama - Cross-platform colored terminal text.
    • docopt - Pythonic command line arguments parser.
    • Gooey - Turn command line programs into a full GUI application with one line
    • Python-Fire - A library for creating command line interfaces from absolutely any Python object.
    • python-prompt-toolkit - A library for building powerful interactive command lines.
  • Productivity Tools

    • aws-cli - A universal command-line interface for Amazon Web Services.
    • cookiecutter - A command-line utility that creates projects from cookiecutters (project templates).
    • doitlive - A tool for live presentations in the terminal.
    • howdoi - Instant coding answers via the command line.
    • httpie - A command line HTTP client, a user-friendly cURL replacement.
    • kube-shell - An integrated shell for working with the Kubernetes CLI.
    • mycli - A Terminal Client for MySQL with AutoCompletion and Syntax Highlighting.
    • PathPicker - Select files out of bash output.
    • percol - Adds flavor of interactive selection to the traditional pipe concept on UNIX.
    • pgcli - Postgres CLI with autocompletion and syntax highlighting.
    • SAWS - A Supercharged AWS CLI.
    • thefuck - Correcting your previous console command.
    • tmuxp - A tmux session manager.
    • try - A dead simple CLI to try out python packages - it's never been easier.

兼容性

Libraries for migrating from Python 2 to 3.

  • Python-Future - The missing compatibility layer between Python 2 and Python 3.
  • Python-Modernize - Modernizes Python code for eventual Python 3 migration.
  • Six - Python 2 and 3 compatibility utilities.

计算机视觉

Libraries for computer vision.

并发和并行

用于并发和并行执行的库。

  • eventlet - Asynchronous framework with WSGI support.
  • gevent - A coroutine-based Python networking library that uses greenlet.
  • multiprocessing - (Python standard library) Process-based "threading" interface.
  • threading - (Python standard library) Higher-level threading interface.
  • Tomorrow - Magic decorator syntax for asynchronous code.
  • uvloop - Ultra fast implementation of asyncio event loop on top of libuv.

组态

用于存储和解析配置选项的库。

  • config - Hierarchical config from the author of logging.
  • ConfigObj - INI file parser with validation.
  • ConfigParser - (Python standard library) INI file parser.
  • profig - Config from multiple formats with value conversion.
  • python-decouple - Strict separation of settings from code.

加密

  • cryptography - A package designed to expose cryptographic primitives and recipes to Python developers.
  • hashids - Implementation of hashids in Python.
  • Paramiko - A Python (2.6+, 3.3+) implementation of the SSHv2 protocol, providing both client and server functionality.
  • Passlib - Secure password storage/hashing library, very high level.
  • PyNacl - Python binding to the Networking and Cryptography (NaCl) library.

数据分析

用于数据分析的库。

  • Blaze - NumPy和Pandas与大数据的接口。
  • Open Mining - Pandas界面中的商业智能(BI)。
  • Orange - 通过可视化编程或脚本进行数据挖掘,数据可视化,分析和机器学习。
  • Pandas - 提供高性能,易于使用的数据结构和数据分析工具的库。
  • Optimus - 使用PySpark后端进行清理,预处理,功能工程,探索性数据分析和简单的机器学习。

数据验证

用于验证数据的库。在许多情况下用于表单。

  • Cerberus - 一个轻量级和可扩展的数据验证库。
  • colander - Validating and deserializing data obtained via XML, JSON, an HTML form post.
  • jsonschema - An implementation of JSON Schema for Python.
  • schema - 用于验证Python数据结构的库。
  • Schematics - Data Structure Validation.
  • valideer - Lightweight extensible data validation and adaptation library.
  • voluptuous - A Python data validation library.

数据可视化

用于可视化数据的库。请参阅: awesome-javascript.

  • Altair - Declarative statistical visualization library for Python.
  • Bokeh - Python的交互式Web绘图。
  • bqplot - Interactive Plotting Library for the Jupyter Notebook
  • ggplot - Same API as ggplot2 for R.
  • Matplotlib - Python 2D绘图库。
  • Pygal - A Python SVG Charts Creator.
  • PyGraphviz - Python interface to Graphviz.
  • PyQtGraph - 交互式和实时2D / 3D /图像绘图和科学/工程小部件。
  • Seaborn - 使用Matplotlib进行统计数据可视化。
  • VisPy - 基于OpenGL的高性能科学可视化。

数据库

Databases implemented in Python.

  • pickleDB - A simple and lightweight key-value store for Python.
  • TinyDB - A tiny, document-oriented database.
  • ZODB - A native object database for Python. A key-value and object graph database.

数据库驱动

用于连接和操作数据库的库

  • MySQL - awesome-mysql

    • mysqlclient - MySQL connector with Python 3 support (mysql-python fork).
    • oursql - A better MySQL connector with support for native prepared statements and BLOBs.
    • PyMySQL - A pure Python MySQL driver compatible to mysql-python.
  • PostgreSQL - awesome-postgres

    • psycopg2 - The most popular PostgreSQL adapter for Python.
    • queries - A wrapper of the psycopg2 library for interacting with PostgreSQL.
    • txpostgres - Twisted based asynchronous driver for PostgreSQL.
  • Other Relational Databases

    • apsw - Another Python SQLite wrapper.
    • dataset - Store Python dicts in a database - works with SQLite, MySQL, and PostgreSQL.
    • pymssql - A simple database interface to Microsoft SQL Server.
  • NoSQL Databases

    • cassandra-python-driver - Python driver for Cassandra.
    • HappyBase - A developer-friendly library for Apache HBase.
    • Plyvel - A fast and feature-rich Python interface to LevelDB.
    • py2neo - Python wrapper client for Neo4j's restful interface.
    • pycassa - Python Thrift driver for Cassandra.
    • PyMongo - The official Python client for MongoDB.
    • redis-py - The Redis Python Client.
    • telephus - Twisted based client for Cassandra.
    • txRedis - Twisted based client for Redis.

日期和时间

Libraries for working with dates and times.

  • Chronyk - 一个Python 3库,用于解析人类编写的时间和日期。
  • dateutil - Extensions to the standard Python datetime module.
  • delorean - A library for clearing up the inconvenient truths that arise dealing with datetimes.
  • moment - A Python library for dealing with dates/times. Inspired by Moment.js.
  • Pendulum - Python datetimes made easy.
  • PyTime - A easy-use Python module which aims to operate date/time/datetime by string.
  • pytz - World timezone definitions, modern and historical. Brings the tz database into Python.
  • when.py - Providing user-friendly functions to help perform common date and time actions.
  • maya - Datetimes for Humans, Maya is mostly built around the headaches and use-cases around parsing datetime data from websites.

调试工具

Libraries for debugging code.

  • pdb-like Debugger

    • ipdb - IPython-enabled pdb.
    • pdb++ - Another drop-in replacement for pdb.
    • pudb - A full-screen, console-based Python debugger.
    • remote-pdb - Remote vanilla PDB (over TCP sockets).
    • wdb - An improbable web debugger through WebSockets.
  • Profiler

    • line_profiler - Line-by-line profiling.
    • memory_profiler - Monitor Memory usage of Python code.
    • Pyflame - Attach this Ptracing Profiler to any processes running Python. Perfect for profiling production webservers.
    • profiling - An interactive Python profiler.
    • vprof - Visual Python profiler.
  • Others

    • IceCream - Inspect variables, expressions, and program execution with a single, simple function call.
    • django-debug-toolbar - Display various debug information for Django.
    • django-devserver - A drop-in replacement for Django's runserver.
    • flask-debugtoolbar - A port of the django-debug-toolbar to flask.
    • hunter - Hunter is a flexible code tracing toolkit.
    • lptrace - strace for Python programs.
    • manhole - Debug service that will accept unix domain socket connections and present the stacktraces for all threads and an interactive prompt.
    • pyelftools - Parsing and analyzing ELF files and DWARF debugging information.
    • pyringe - Debugger capable of attaching to and injecting code into Python processes.

深度学习

神经网络和深度学习的框架。请参阅: awesome-deep-learning.

  • Caffe - A fast open framework for deep learning..
  • Keras - 一个高级神经网络库,能够在TensorFlow或Theano之上运行。
  • MXNet - A deep learning framework designed for both efficiency and flexibility.
  • Neupy - Running and testing different Artificial Neural Networks algorithms.
  • Pytorch - Tensors and Dynamic neural networks in Python with strong GPU acceleration.
  • Serpent.AI - Game agent framework. Use any video game as a deep learning sandbox.
  • TensorFlow - Google创建的最受欢迎的深度学习框架。
  • Theano - A library for fast numerical computation.

DevOps工具

DevOps的软件和库

  • Ansible - A radically simple IT automation platform.
  • Cloud-Init - A multi-distribution package that handles early initialization of a cloud instance.
  • cuisine - Chef-like functionality for Fabric.
  • Docker Compose - Fast, isolated development environments using Docker.
  • Fabric - A simple, Pythonic tool for remote execution and deployment.
  • Fabtools - Tools for writing awesome Fabric files.
  • honcho - A Python clone of Foreman, for managing Procfile-based applications.
  • OpenStack - Open source software for building private and public clouds.
  • pexpect - Controlling interactive programs in a pseudo-terminal like GNU expect.
  • psutil - A cross-platform process and system utilities module.
  • SaltStack - Infrastructure automation and management system.
  • supervisor - Supervisor process control system for UNIX.

Distribution

用于创建发布分发的打包可执行文件的库

  • dh-virtualenv - Build and distribute a virtualenv as a Debian package.
  • Nuitka - Compile scripts, modules, packages to an executable or extension module.
  • py2app - Freezes Python scripts (Mac OS X).
  • py2exe - Freezes Python scripts (Windows).
  • PyInstaller - Converts Python programs into stand-alone executables (cross-platform).
  • pynsist - A tool to build Windows installers, installers bundle Python itself.

文档

用于生成项目文档的库

  • Sphinx - Python文档生成器。

  • MkDocs - Markdown友好文档生成器。
  • pdoc - Epydoc replacement to auto generate API documentation for Python libraries.
  • Pycco - The literate-programming-style documentation generator.

下载

Libraries for downloading.

  • s3cmd - A command line tool for managing Amazon S3 and CloudFront.
  • s4cmd - Super S3 command line tool, good for higher performance.
  • you-get - A YouTube/Youku/Niconico video downloader written in Python 3.
  • youtube-dl - A small command-line program to download videos from YouTube.

电子商务

用于电子商务和支付的框架和库

  • alipay - 用于Python的非官方支付宝API。
  • Cartridge - A shopping cart app built using the Mezzanine.
  • django-oscar - An open-source e-commerce framework for Django.
  • django-shop - 基于Django的商店系统。
  • merchant - A Django app to accept payments from various payment processors.
  • money - Money class with optional CLDR-backed locale-aware formatting and an extensible currency exchange solution.
  • python-currencies - Display money format and its filthy currencies.
  • forex-python - 外汇汇率,比特币价格指数和货币转换。
  • saleor - An e-commerce storefront for Django.
  • shoop - 基于Django的开源电子商务平台。

编辑器插件和IDE

  • Emacs

    • Elpy - Emacs Python Development Environment.
  • Sublime Text

    • Anaconda - Anaconda turns your Sublime Text 3 in a full featured Python development IDE.
    • SublimeJEDI - A Sublime Text plugin to the awesome auto-complete library Jedi.
  • Vim

    • Jedi-vim - Vim bindings for the Jedi auto-completion library for Python.
    • Python-mode - 用于将Vim转换为Python IDE的一体化插件。
    • YouCompleteMe - Includes Jedi-based completion engine for Python.
  • Visual Studio

    • PTVS - Python Tools for Visual Studio.
  • Visual Studio Code

    • Python - An extension with rich support for the Python language, with features including linting, IntelliSense, formatting, refactoring, debugging, unit tests, and jupyter support.
    • Magic Python - Cutting edge Python syntax highlighter for Sublime Text, Atom, and Visual Studio Code. Used by GitHub to highlight your Python code!
  • IDE

    • LiClipse - Free polyglot IDE based on Eclipse. Uses PyDev for Python support.
    • PyCharm - Commercial Python IDE by JetBrains. Has free community edition available.
    • Spyder - Open Source Python IDE.

电子邮件

用于发送和解析电子邮件的库

  • envelopes - Mailing for human beings.
  • flanker - A email address and Mime parsing library.
  • imbox - Python IMAP for Humans.
  • inbox.py - Python SMTP Server for Humans.
  • lamson - Pythonic SMTP Application Server.
  • Marrow Mailer - High-performance extensible mail delivery framework.
  • modoboa - A mail hosting and management platform including a modern and simplified Web UI.
  • Nylas Sync Engine - Providing a RESTful API on top of a powerful email sync platform.
  • yagmail - Yet another Gmail/SMTP client.

环境管理

用于Python版本和环境管理的库

  • Pipenv - Sacred Marriage of Pipfile, Pip, & Virtualenv.
  • p - Dead simple interactive Python version management.
  • pyenv - Simple Python version management.
  • venv - (Python standard library in Python 3.3+) Creating lightweight virtual environments.
  • virtualenv - 创建独立Python环境的工具。
  • virtualenvwrapper - A set of extensions to virtualenv.

Files

用于文件操作和MIME类型检测的库

  • imghdr -(Python标准库)确定图像的类型。
  • mimetypes - (Python标准库)将文件名映射到MIME类型。
  • path.py - A module wrapper for os.path.
  • pathlib - (Python standard library in Python 3.4+) An cross-platform, object-oriented path library.
  • python-magic - A Python interface to the libmagic file type identification library.
  • Unipath - 面向对象的文件/目录操作方法。
  • watchdog - API and shell utilities to monitor file system events.

外部函数接口

用于提供外部函数接口的库

  • cffi - Python的外部函数接口,用于调用C代码。
  • ctypes - (Python standard library) Foreign Function Interface for Python calling C code.
  • PyCUDA - A Python wrapper for Nvidia's CUDA API.
  • SWIG - Simplified Wrapper and Interface Generator.

Forms

用于处理表单的库

  • Deform - Python HTML form generation library influenced by the formish form generation library.
  • django-bootstrap3 - Bootstrap 3 integration with Django.
  • django-crispy-forms - A Django app which lets you create beautiful forms in a very elegant and DRY way.
  • django-remote-forms - A platform independent Django form serializer.
  • WTForms - 灵活的表单验证和呈现库。

Functional Programming

Functional Programming with Python.

  • CyToolz - Cython implementation of Toolz: High performance functional utilities.
  • fn.py - Functional programming in Python: implementation of missing features to enjoy FP.
  • funcy - A fancy and practical functional tools.
  • Toolz - A collection of functional utilities for iterators, functions, and dictionaries.

GUI

用于处理图形用户界面应用程序的库

  • curses - Built-in wrapper for ncurses used to create terminal GUI applications.
  • Eel - Little library for making simple Electron-like offline HTML/JS GUI apps, with full access to Python capabilities and libraries.
  • enaml - Creating beautiful user-interfaces with Declaratic Syntax like QML.
  • Flexx - Flexx is a pure Python toolkit for creating GUI's, that uses web technology for its rendering.
  • kivy - A library for creating NUI applications, running on Windows, Linux, Mac OS X, Android and iOS.
  • pyglet - A cross-platform windowing and multimedia library for Python.
  • PyGObject - Python Bindings for GLib/GObject/GIO/GTK+ (GTK+3).
  • PyQt - Python bindings for the Qt cross-platform application and UI framework, with support for both Qt v4 and Qt v5 frameworks.
  • PySide - Python bindings for the Qt cross-platform application and UI framework, supporting the Qt v4 framework.
  • pywebview - A lightweight cross-platform native wrapper around a webview component that allows to display HTML content in its own native dedicated window.
  • Tkinter - Tkinter is Python's de-facto standard GUI package.
  • Toga - A Python native, OS native GUI toolkit.
  • urwid - A library for creating terminal GUI applications with strong support for widgets, events, rich colors, etc.
  • wxPython - A blending of the wxWidgets C++ class library with the Python.

游戏开发

令人敬畏的游戏开发库

  • Cocos2d - cocos2d is a framework for building 2D games, demos, and other graphical/interactive applications. It is based on pyglet.
  • Panda3D - 3D game engine developed by Disney and maintained by Carnegie Mellon's Entertainment Technology Center. Written in C++, completely wrapped in Python.
  • Pygame - Pygame is a set of Python modules designed for writing games.
  • PyOgre - Python bindings for the Ogre 3D render engine, can be used for games, simulations, anything 3D.
  • PyOpenGL - Python ctypes bindings for OpenGL and it's related APIs.
  • PySDL2 - A ctypes based wrapper for the SDL2 library.
  • RenPy - A Visual Novel engine.

地理位置

Libraries for geocoding addresses and working with latitudes and longitudes.

  • django-countries - A Django app that provides country choices for use with forms, flag icons static files, and a country field for models.
  • GeoDjango - 世界级的地理网络框架。
  • GeoIP - Python API for MaxMind GeoIP Legacy Database.
  • geojson - Python bindings and utilities for GeoJSON.
  • geopy - Python Geocoding Toolbox.
  • pygeoip - Pure Python GeoIP API.

HTML Manipulation

用于处理HTML和XML的库

  • BeautifulSoup - Providing Pythonic idioms for iterating, searching, and modifying HTML or XML.
  • bleach - A whitelist-based HTML sanitization and text linkification library.
  • cssutils - A CSS library for Python.
  • html5lib - A standards-compliant library for parsing and serializing HTML documents and fragments.
  • lxml - A very fast, easy-to-use and versatile library for handling HTML and XML.
  • MarkupSafe - Implements a XML/HTML/XHTML Markup safe string for Python.
  • pyquery - A jQuery-like library for parsing HTML.
  • untangle - Converts XML documents to Python objects for easy access.
  • WeasyPrint - A visual rendering engine for HTML and CSS that can export to PDF.
  • xmldataset - Simple XML Parsing.
  • xmltodict - Working with XML feel like you are working with JSON.

HTTP

用于处理HTTP的库

  • grequests - requests + gevent for asynchronous HTTP requests.
  • httplib2 - Comprehensive HTTP client library.
  • requests - HTTP Requests for Humans™.
  • treq - Python requests like API built on top of Twisted's HTTP client.
  • urllib3 - A HTTP library with thread-safe connection pooling, file post support, sanity friendly.

Hardware

Libraries for programming with hardware.

  • ino - Command line toolkit for working with Arduino.
  • keyboard - Hook and simulate global keyboard events on Windows and Linux.
  • mouse - Hook and simulate global mouse events on Windows and Linux.
  • Pingo - Pingo provides a uniform API to program devices like the Raspberry Pi, pcDuino, Intel Galileo, etc.
  • PyUserInput - A module for cross-platform control of the mouse and keyboard.
  • scapy - A brilliant packet manipulation library.
  • wifi - 用于在Linux上使用WiFi的Python库和命令行工具。

图像处理

用于处理图像的库

  • hmap - Image histogram remapping.
  • imgSeek - A project for searching a collection of images using visual similarity.
  • nude.py - Nudity detection.
  • pagan - Retro identicon (Avatar) generation based on input string and hash.
  • pillow - Pillow is the friendly PIL fork.
  • pyBarcode - Create barcodes in Python without needing PIL.
  • pygram - Instagram-like image filters.
  • python-qrcode - A pure Python QR Code generator.
  • Quads - Computer art based on quadtrees.
  • scikit-image - A Python library for (scientific) image processing.
  • thumbor - A smart imaging service. It enables on-demand crop, re-sizing and flipping of images.
  • wand - Python bindings for MagickWand, C API for ImageMagick.

Implementations

Implementations of Python.

  • CLPython - Implementation of the Python programming language written in Common Lisp.
  • CPython - Default, most widely used implementation of the Python programming language written in C.
  • Cython - Optimizing Static Compiler for Python. Uses type mixins to compile Python into C or C++ modules resulting in large performance gains
  • Grumpy - More compiler than interpreter as more powerful CPython2.7 replacement (alpha).
  • IronPython - Implementation of the Python programming language written in C# targeting the .NET Framework and Mono.
  • Jython - Implementation of Python programming language written in Java for the Java virtual machine (JVM).
  • MicroPython - MicroPython - a lean and efficient Python programming language implementation for microcontrollers and constrained systems
  • Numba - Python JIT compiler to LLVM aimed at scientific Python.
  • PeachPy - x86-64 assembler embedded in Python. Can be used as inline assembler for Python or as a stand-alone assembler for Windows, Linux, OS X, Native Client and Go.
  • Pyjion - A JIT for Python based upon CoreCLR.
  • PyPy - Implementation of the Python programming language written in RPython and translated into C. PyPy focuses on speed, efficiency and compatibility with the original CPython interpreter. The interpreter uses black magic to make Python very fast without having to add in additional type information.
  • PySec - Hardened version of python that makes it easier for security professionals and developers to write applications more resilient to attacks and manipulations.
  • Pyston - A Python implementation built using LLVM and modern JIT techniques with the goal of achieving good performance.
  • Stackless Python - An enhanced version of the Python programming language which allows programmers to reap the benefits of thread-based programming without the performance and complexity problems associated with conventional threads.

Interactive Interpreter

Interactive Python interpreters (REPL).

国际化

Libraries for working with i18n.

  • Babel - Python的国际化库。
  • PyICU - A wrapper of International Components for Unicode C++ library (ICU).

Job Scheduler

Libraries for scheduling jobs.

  • APScheduler - A light but powerful in-process task scheduler that lets you schedule functions.
  • django-schedule - A calendaring app for Django.
  • doit - A task runner and build tool.
  • gunnery - Multipurpose task execution tool for distributed systems with web-based interface.
  • Joblib - A set of tools to provide lightweight pipelining in Python.
  • Plan - Writing crontab file in Python like a charm.
  • schedule - Python job scheduling for humans.
  • Spiff - A powerful workflow engine implemented in pure Python.
  • TaskFlow - A Python library that helps to make task execution easy, consistent and reliable.

Logging

Libraries for generating and working with logs.

  • Eliot - Logging for complex & distributed systems.
  • logbook - Logging replacement for Python.
  • logging - (Python standard library) Logging facility for Python.
  • raven - Python client for Sentry, a log/error tracking, crash reporting and aggregation platform for web applications.

Machine Learning

Libraries for Machine Learning. See: awesome-machine-learning.

  • H2O - Open Source Fast Scalable Machine Learning Platform.
  • Metrics - Machine learning evaluation metrics.
  • NuPIC - Numenta Platform for Intelligent Computing.
  • scikit-learn - The most popular Python library for Machine Learning.
  • Spark ML - Apache Spark's scalable Machine Learning library.
  • vowpal_porpoise - A lightweight Python wrapper for Vowpal Wabbit.
  • xgboost - A scalable, portable, and distributed gradient boosting library.

MapReduce

Frameworks and libraries for MapReduce.

  • PySpark - Apache Spark Python API.
  • luigi - A module that helps you build complex pipelines of batch jobs.
  • mrjob - Run MapReduce jobs on Hadoop or Amazon Web Services.
  • streamparse - Run Python code against real-time streams of data. Integrates with Apache Storm.
  • dask - A flexible parallel computing library for analytic computing.

Microsoft Windows

Python programming on Microsoft Windows.

  • Python(x,y) - Scientific-applications-oriented Python Distribution based on Qt and Spyder.
  • pythonlibs - Unofficial Windows binaries for Python extension packages.
  • PythonNet - Python Integration with the .NET Common Language Runtime (CLR).
  • PyWin32 - Python Extensions for Windows.
  • WinPython - Portable development environment for Windows 7/8.

Miscellaneous

Useful libraries or tools that don't fit in the categories above.

  • blinker - A fast Python in-process signal/event dispatching system.
  • itsdangerous - Various helpers to pass trusted data to untrusted environments.
  • pluginbase - A simple but flexible plugin system for Python.
  • Pychievements - A framework for creating and tracking achievements.
  • Tryton - A general purpose business framework.

Natural Language Processing

Libraries for working with human languages.

  • gensim - Topic Modelling for Humans.
  • Jieba - Chinese text segmentation.
  • langid.py - Stand-alone language identification system.
  • NLTK - A leading platform for building Python programs to work with human language data.
  • Pattern - A web mining module for the Python.
  • polyglot - Natural language pipeline supporting hundreds of languages.
  • SnowNLP - A library for processing Chinese text.
  • spaCy - A library for industrial-strength natural language processing in Python and Cython.
  • TextBlob - Providing a consistent API for diving into common NLP tasks.
  • PyTorch-NLP - A toolkit enabling rapid deep learning NLP prototyping for research.

Network Virtualization

Tools and libraries for Virtual Networking and SDN (Software Defined Networking).

  • Mininet - A popular network emulator and API written in Python.
  • POX - An open source development platform for Python-based Software Defined Networking (SDN) control applications, such as OpenFlow SDN controllers.
  • Pyretic - A member of the Frenetic family of SDN programming languages that provides powerful abstractions over network switches or emulators.
  • SDX Platform - SDN based IXP implementation that leverages Mininet, POX and Pyretic.

Networking

用于网络编程的库

  • asyncio - (Python standard library) Asynchronous I/O, event loop, coroutines and tasks.
  • diesel - Greenlet-based event I/O Framework for Python.
  • pulsar - Event-driven concurrent framework for Python.
  • pyzmq - A Python wrapper for the ZeroMQ message library.
  • Twisted - An event-driven networking engine.
  • txZMQ - Twisted based wrapper for the ZeroMQ message library.
  • NAPALM - Cross-vendor API to manipulate network devices.

News Feed

用于构建用户活动的库

ORM

Libraries that implement Object-Relational Mapping or data mapping techniques.

  • Relational Databases

    • Django Models - A part of Django.
    • SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper.

    • Orator - The Orator ORM provides a simple yet beautiful ActiveRecord implementation.
    • Peewee - A small, expressive ORM.
    • PonyORM - ORM that provides a generator-oriented interface to SQL.
    • pyDAL - A pure Python Database Abstraction Layer.
    • python-sql - Write SQL queries pythonically.
  • NoSQL Databases

  • Others

    • butterdb - A Python ORM for Google Drive Spreadsheets.
    • dataset - A JSON-based database.

Package Management

Libraries for package and dependency management.

  • pip - The Python package and dependency manager.

  • conda - Cross-platform, Python-agnostic binary package manager.
  • Curdling - Curdling is a command line tool for managing Python packages.
  • pip-tools - A set of tools to keep your pinned Python dependencies fresh.
  • wheel - The new standard of Python distribution and are intended to replace eggs.

Package Repositories

Local PyPI repository server and proxies.

  • warehouse - Next generation Python Package Repository (PyPI).

  • bandersnatch - PyPI mirroring tool provided by Python Packaging Authority (PyPA).
  • devpi - PyPI server and packaging/testing/release tool.
  • localshop - Local PyPI server (custom packages and auto-mirroring of pypi).

Permissions

Libraries that allow or deny users access to data or functionality.

  • Carteblanche - Module to align code with thoughts of users and designers. Also magically handles navigation and permissions.
  • django-guardian - Implementation of per object permissions for Django 1.2+
  • django-rules - A tiny but powerful app providing object-level permissions to Django, without requiring a database.

Processes

Libraries for starting and communicating with OS processes.

Queue

Libraries for working with event and task queues.

  • celery - An asynchronous task queue/job queue based on distributed message passing.
  • huey - Little multi-threaded task queue.
  • mrq - Mr. Queue - A distributed worker task queue in Python using Redis & gevent.
  • rq - Simple job queues for Python.
  • simpleq - A simple, infinitely scalable, Amazon SQS based queue.

Recommender Systems

Libraries for building recommender systems.

  • annoy - Approximate Nearest Neighbors in C++/Python optimized for memory usage.
  • fastFM - A library for Factorization Machines.
  • implicit - A fast Python implementation of collaborative filtering for implicit datasets.
  • libffm - A library for Field-aware Factorization Machine (FFM).
  • LightFM - A Python implementation of a number of popular recommendation algorithms.
  • Spotlight - Deep recommender models using PyTorch.
  • surprise - A scikit for building and analyzing recommender systems.
  • TensorRec - A Recommendation Engine Framework in TensorFlow.

RESTful API

Libraries for developing RESTful APIs.

  • Django

  • Flask

    • eve - REST API framework powered by Flask, MongoDB and good intentions.
    • flask-api-utils - Taking care of API representation and authentication for Flask.
    • flask-api - Browsable Web APIs for Flask.
    • flask-restful - Quickly building REST APIs for Flask.
    • flask-restless - Generating RESTful APIs for database models defined with SQLAlchemy.
  • Pyramid

    • cornice - A RESTful framework for Pyramid.
  • Framework agnostic

    • falcon - A high-performance framework for building cloud APIs and web app backends.
    • hug - A Python3 framework for cleanly exposing APIs over HTTP and the Command Line with automatic documentation and validation.
    • restless - Framework agnostic REST framework based on lessons learned from Tastypie.
    • ripozo - Quickly creating REST/HATEOAS/Hypermedia APIs.
    • sandman - Automated REST APIs for existing database-driven systems.
    • apistar - A smart Web API framework, designed for Python 3.

RPC Servers

RPC-compatible servers.

Science

Libraries for scientific computing.

  • astropy - A community Python library for Astronomy.
  • bcbio-nextgen - Providing best-practice pipelines for fully automated high throughput sequencing analysis.
  • bccb - Collection of useful code related to biological analysis.
  • Biopython - Biopython is a set of freely available tools for biological computation.
  • cclib - A library for parsing and interpreting the results of computational chemistry packages.
  • Colour - A colour science package implementing a comprehensive number of colour theory transformations and algorithms.
  • NetworkX - A high-productivity software for complex networks.
  • NIPY - A collection of neuroimaging toolkits.
  • NumPy - A fundamental package for scientific computing with Python.
  • Open Babel - A chemical toolbox designed to speak the many languages of chemical data.
  • ObsPy - A Python toolbox for seismology.
  • PyDy - Short for Python Dynamics, used to assist with workflow in the modeling of dynamic motion.
  • PyMC - Markov Chain Monte Carlo sampling toolkit.
  • QuTiP - Quantum Toolbox in Python.
  • RDKit - Cheminformatics and Machine Learning Software.
  • SciPy - A Python-based ecosystem of open-source software for mathematics, science, and engineering.
  • statsmodels - Statistical modeling and econometrics in Python.
  • SymPy - A Python library for symbolic mathematics.
  • Zipline - A Pythonic algorithmic trading library.
  • SimPy - A process-based discrete-event simulation framework.

Search

Libraries and software for indexing and performing search queries on data.

Serialization

Libraries for serializing complex data types

  • marshmallow - marshmallow is an ORM/ODM/framework-agnostic library for converting complex datatypes, such as objects, to and from native Python datatypes.

Serverless Frameworks

Frameworks for developing serverless Python code.

  • apex - Build, deploy, and manage AWS Lambda functions with ease.
  • python-lambda - A toolkit for developing and deploying Python code in AWS Lambda.
  • Zappa - A tool for deploying WSGI applications on AWS Lambda and API Gateway.

Specific Formats Processing

Libraries for parsing and manipulating specific text formats.

  • General

    • tablib - A module for Tabular Datasets in XLS, CSV, JSON, YAML.
  • Office

    • Marmir - Takes Python data structures and turns them into spreadsheets.
    • openpyxl - A library for reading and writing Excel 2010 xlsx/xlsm/xltx/xltm files.
    • pyexcel - Providing one API for reading, manipulating and writing csv, ods, xls, xlsx and xlsm files.
    • python-docx - Reads, queries and modifies Microsoft Word 2007/2008 docx files.
    • python-pptx - Python library for creating and updating PowerPoint (.pptx) files.
    • relatorio - Templating OpenDocument files.
    • unoconv - Convert between any document format supported by LibreOffice/OpenOffice.
    • XlsxWriter - A Python module for creating Excel .xlsx files.
    • xlwings - A BSD-licensed library that makes it easy to call Python from Excel and vice versa.
    • xlwt / xlrd - Writing and reading data and formatting information from Excel files.
  • PDF

    • PDFMiner - A tool for extracting information from PDF documents.
    • PyPDF2 - A library capable of splitting, merging and transforming PDF pages.
    • ReportLab - Allowing Rapid creation of rich PDF documents.
  • Markdown

    • Mistune - Fastest and full featured pure Python parsers of Markdown.
    • Python-Markdown - A Python implementation of John Gruber’s Markdown.
  • YAML

    • PyYAML - YAML implementations for Python.
  • CSV

    • csvkit - Utilities for converting to and working with CSV.
  • Archive

    • unp - A command line tool that can unpack archives easily.

Static Site Generator

Static site generator is a software that takes some text + templates as input and produces HTML files on the output.

  • Cactus - Static site generator for designers.
  • Hyde - Jinja2-based static web site generator.
  • Lektor - An easy to use static CMS and blog engine.
  • Nikola - A static website and blog generator.
  • Pelican - Uses Markdown or ReST for content and Jinja 2 for themes. Supports DVCS, Disqus. AGPL.
  • Tinkerer - Tinkerer is a blogging engine/.static website generator powered by Sphinx.

Tagging

Libraries for tagging items.

Template Engine

Libraries and tools for templating and lexing.

  • Genshi - Python templating toolkit for generation of web-aware output.
  • Jinja2 - A modern and designer friendly templating language.
  • Mako - Hyperfast and lightweight templating for the Python platform.

Testing

Libraries for testing codebases and generating test data.

  • Testing Frameworks

    • hypothesis - Hypothesis is an advanced Quickcheck style property based testing library.
    • mamba - The definitive testing tool for Python. Born under the banner of BDD.
    • nose - A nicer unittest for Python.
    • nose2 - The successor to nose, based on unittest2.
    • pytest - A mature full-featured Python testing tool.
    • Robot Framework - A generic test automation framework.
    • unittest - (Python standard library) Unit testing framework.
  • Test Runners

    • green - A clean, colorful test runner.
    • tox - Auto builds and tests distributions in multiple Python versions
  • GUI / Web Testing

    • locust - Scalable user load testing tool written in Python.
    • PyAutoGUI - PyAutoGUI is a cross-platform GUI automation Python module for human beings.
    • Selenium - Python bindings for Selenium WebDriver.
    • sixpack - A language-agnostic A/B Testing framework.
    • splinter - Open source tool for testing web applications.
  • Mock

    • doublex - Powerful test doubles framework for Python.
    • freezegun - Travel through time by mocking the datetime module.
    • httmock - A mocking library for requests for Python 2.6+ and 3.2+.
    • httpretty - HTTP request mock tool for Python.
    • mock - (Python standard library) A mocking and patching library.
    • Mocket - Socket Mock Framework plus HTTP[S]/asyncio/gevent mocking library with recording/replaying capability.
    • responses - A utility library for mocking out the requests Python library.
    • VCR.py - Record and replay HTTP interactions on your tests.
  • Object Factories

    • factory_boy - A test fixtures replacement for Python.
    • mixer - Another fixtures replacement. Supported Django, Flask, SQLAlchemy, Peewee and etc.
    • model_mommy - Creating random fixtures for testing in Django.
  • Code Coverage

  • Fake Data

    • mimesis - is a Python library that help you generate fake data.
    • fake2db - Fake database generator.
    • faker - A Python package that generates fake data.
    • radar - Generate random datetime / time.
  • Error Handler

    • FuckIt.py - FuckIt.py uses state-of-the-art technology to make sure your Python code runs whether it has any right to or not.

Text Processing

Libraries for parsing and manipulating plain texts.

  • General

    • chardet - Python 2/3 compatible character encoding detector.
    • difflib - (Python standard library) Helpers for computing deltas.
    • ftfy - Makes Unicode text less broken and more consistent automagically.
    • fuzzywuzzy - Fuzzy String Matching.
    • Levenshtein - Fast computation of Levenshtein distance and string similarity.
    • pangu.py - Spacing texts for CJK and alphanumerics.
    • pyfiglet - An implementation of figlet written in Python.
    • pypinyin - Convert Chinese hanzi to pinyin.
    • shortuuid - A generator library for concise, unambiguous and URL-safe UUIDs.
    • textdistance - Compute distance between sequences. 30+ algorithms, pure python implementation, common interface, optional external libs usage.
    • unidecode - ASCII transliterations of Unicode text.
    • uniout - Print readable chars instead of the escaped string.
    • xpinyin - A library to translate Chinese hanzi (漢字) to pinyin (拼音).
  • Slugify

    • awesome-slugify - A Python slugify library that can preserve unicode.
    • python-slugify - A Python slugify library that translates unicode to ASCII.
    • unicode-slugify - A slugifier that generates unicode slugs with Django as a dependency.
  • Parser

    • phonenumbers - Parsing, formatting, storing and validating international phone numbers.
    • PLY - Implementation of lex and yacc parsing tools for Python.
    • Pygments - A generic syntax highlighter.
    • pyparsing - A general purpose framework for generating parsers.
    • python-nameparser - Parsing human names into their individual components.
    • python-user-agents - Browser user agent parser.
    • sqlparse - A non-validating SQL parser.

Third-party APIs

Libraries for accessing third party services APIs. See: List of Python API Wrappers and Libraries.

URL Manipulation

Libraries for parsing URLs.

  • furl - A small Python library that makes parsing and manipulating URLs easy.
  • purl - A simple, immutable URL class with a clean API for interrogation and manipulation.
  • pyshorteners - A pure Python URL shortening lib.
  • short_url - Python implementation for generating Tiny URL and bit.ly-like URLs.
  • webargs - A friendly library for parsing HTTP request arguments, with built-in support for popular web frameworks, including Flask, Django, Bottle, Tornado, and Pyramid.

Video

Libraries for manipulating video and GIFs.

  • moviepy - A module for script-based movie editing with many formats, including animated GIFs.
  • scikit-video - Video processing routines for SciPy.

WSGI Servers

WSGI-compatible web servers.

  • bjoern - Asynchronous, very fast and written in C.
  • fapws3 - Asynchronous (network side only), written in C.
  • gunicorn - Pre-forked, partly written in C.
  • meinheld - Asynchronous, partly written in C.
  • netius - Asynchronous, very fast.
  • rocket - Multi-threaded.
  • uWSGI - A project aims at developing a full stack for building hosting services, written in C.
  • waitress - Multi-threaded, powers Pyramid.
  • Werkzeug - A WSGI utility library for Python that powers Flask and can easily be embedded into your own projects.

Web Content Extracting

Libraries for extracting web contents.

  • Haul - An Extensible Image Crawler.
  • html2text - Convert HTML to Markdown-formatted text.
  • lassie - Web Content Retrieval for Humans.
  • micawber - A small library for extracting rich content from URLs.
  • newspaper - News extraction, article extraction and content curation in Python.
  • python-goose - HTML Content/Article Extractor.
  • python-readability - Fast Python port of arc90's readability tool.
  • requests-html - Pythonic HTML Parsing for Humans.
  • sanitize - Bringing sanity to world of messed-up data.
  • sumy - A module for automatic summarization of text documents and HTML pages.
  • textract - Extract text from any document, Word, PowerPoint, PDFs, etc.
  • toapi - Every web site provides APIs.

Web Crawling & Web Scraping

Libraries to automate data extraction from websites.

  • cola - A distributed crawling framework.
  • Demiurge - PyQuery-based scraping micro-framework.
  • feedparser - Universal feed parser.
  • Grab - Site scraping framework.
  • MechanicalSoup - A Python library for automating interaction with websites.
  • portia - Visual scraping for Scrapy.
  • pyspider - A powerful spider system.
  • RoboBrowser - A simple, Pythonic library for browsing the web without a standalone web browser.
  • Scrapy - A fast high-level screen scraping and web crawling framework.

Web Frameworks

Full stack web frameworks.

WebSocket

Libraries for working with WebSocket.

Services

Online tools and APIs to simplify development.

Continuous Integration

See: awesome-CIandCD.

  • CircleCI - A CI service that can run very fast parallel testing. (GitHub only)
  • Travis CI - A popular CI service for your open source and private projects. (GitHub only)
  • Vexor CI - A continuous integration tool for private apps with pay-per-minute billing model.
  • Wercker - A Docker-based platform for building and deploying applications and microservices.

Code Quality

  • Codacy - Automated Code Review to ship better code, faster.
  • Codecov - Code coverage dashboard.
  • CodeFactor - Automated Code Review for Git.
  • Landscape - Hosted continuous Python code metrics.

Resources

Where to discover new Python libraries.

Podcasts

Twitter

Websites

Weekly

Other Awesome Lists

List of lists.

Contributing

Your contributions are always welcome! Please take a look at the contribution guidelines first.

I will keep some pull requests open if I'm not sure whether those libraries are awesome, you could vote for them by adding :+1: to them. Pull requests will be merged when their votes reach 20.


If you have any question about this opinionated list, do not hesitate to contact me @vinta on Twitter or open an issue on GitHub.

构建系统

下面是一些 C 项目的自动化构建和测试工具。

  • aimake:一个被设计来避免复杂配置的构建工具。GNU GPL3 或更高版本。官网
  • Autoconf:一个可扩展的 M4 宏指令包,提供命令行脚本来自动配置软件源码包,是 Autotools 的一部分。GNU GPL3 或更高版本。官网
  • Automake:一个自动生成符合 GNU 代码标准的 Makefile.in 文件的工具。需要与 Autoconf 配合使用,它也是 Autotools 的一部分。GNU GPL3 或更高版本。官网
  • Jam:一个构建系统,它被设计的比make更加易用。隐式地理解 C 的构建规则。Jam License官网
  • Libtool:一个通用库支持脚本,是 Autotools 的一部分。GNU GPL3 或更高版本。官网
  • Meson:一个非常快,用户友好的构建系统,基于 Ninja。Apache2.0官网

编译器

  • Clang:一个基于 LLVM 的 C 的编译器,支持 C11 标准。NCSA官网
  • CompCert:一个经过充分验证的 C 编译器。支持几乎所有的 C89 标准。GNU GPL2.1 或更高版本。官网
  • GCC:在它的编译器集合中提供了 C 编译器。支持 C11 和 OpenMP 的标准。GNU GPL3 或更高版本。官网
  • PCC:一个值得尊敬的 C 编译器,支持 C99 标准。Various licenses,完全免费。官网
  • TCC:一个迷你,速度快的 C 编译器,支持 C99(除了复杂的类型)。 LGPL2.1官网

加密

数据库

下面列出了基于 C API 的数据库和数据存储

  • BerkeleyDB:一个高性能的嵌入式键值对数据库。GNU AGPLv3官网
  • Hiredis:一个极简的 Redis 客户端。3-clause BSD官网
  • LMDB:一个极快,极简的嵌入式键值对数据存储系统。newOpenLDAP官网
  • MariaDB:一个强壮,可扩展和可靠的 SQL 服务器,设计来作为 MySQL 的替代品。3-clause BSD官网
  • mongo-c-driver:一个高性能的 MongoDB 客户端。Apache2.0.官网
  • PostgreSQL:一个强大的对象关系数据库系统。PostgreSQL licence官网
  • recutils:一个工具和 C 库的集合,用于访问可编辑,纯文本的名为 recfiles 的数据库文件。GNU GPL3 或更高版本。官网
  • Redis:一个先进的键值对存储系统。3-clause BSD官网
  • sophia:一个现代,可嵌入的键值对数据库。FreeBSD官网
  • SQLite:一个自包含,无服务器,零配置,支持事务的 SQL 数据库引擎,包括 C 接口。公开领域。官网
  • UnQLite:一个自包含,无服务器,零配置,支持事务的 NoSQL 数据库引擎,包括 C 接口。FreeBSD官网

文档生成

  • Cxref:生成 C 程序的文档,支持 LaTeX,HTML, RTF 或者 SGML 的格式。GPL2.1官网
  • DocOnce:一种朴素的标签标记语言,可以用来生成多种格式的文档。BSD-3clause.官网
  • Doxygen:一个事实上的标准工具,用于从注释的代码中生成 C 文档。能够生成多种格式的文档。GNU GPL2.1官网
  • GTK-Doc:一个从注释的代码中生成 C 文档的工具,支持 Autotools GNU GPL2.1(代码), GNU FDL1.1官网

编辑器

这些是特别精致,IDE 类型的编辑器。如果你想要一个程序员的文本编辑器,看别的地方。此外,不管你选择哪一款编辑器,它都支持 C。

环境

下面列出了被设计来引领 Windows 进入支持 C 的 21 世纪的技术。

框架

这一节包括提供数据结构的大型库和你所期待“现代”的标准库。

  • APR:Apache Portable Runtime;另一个跨平台的实用函数库。Apache2.0官网
  • C Algorithms:一个常用算法和数据结构的集合。官网
  • CPL:The Common Pipeline Library;一系列详尽,高效和强壮的软件工具包。GNU GPL2.1官网
  • EFL:一个大型实用数据结构和函数的的集合。多种许可证,完全免费。官网
  • GLib:一个便携,高效和强大的实用函数和数据结构库。GNU LGPL2.1官网
  • GIO:一个现代和易用的 VFS API。[GNU LGPL2.1]。官网
  • GObject:一个 C 的面向对象系统和对象模型。GNU LGPL2.1官网
  • libnih:一个轻量级的 C 函数和数据结构库。GNU GPL2.1官网
  • libU:一个提供基本实用函数的迷你库,包括内存分配,字符串处理和日志功能。官网
  • PBL:一个包括实用函数,特色数据结构等的大型库。GNU LGPL2.1及更高版本(库),GNU GPL2.1及更高版本(测试代码)。官网
  • qlibc:一个简单且强大的 C 库,当我们想要小且轻的库时,可作为 Glib 的替代品。qLib license (类似于 FreeBSD)。官网
  • stb:一系列单文件 C 库。公共领域。官网
  • libcstl:标准C语言通用数据结构和常用算法库。官网

游戏编程

引擎

这些作为 C 游戏编程代码的例子。

资源

这些是筛选过的,对游戏编程有用的库。

  • Allegro:一个跨平台,视频游戏开发和多媒体库。zlib官网
  • Chipmunk2D:一个快且轻量级的 2D 游戏物理库。Expat官网
  • CSFML:一个用 C 封装的 SFMLzlib官网
  • FreeGLUT:一个替代性的 OpenGL 实用工具包。允许用 OpenGL 上下文创建和管理窗口。X11官网
  • GLFW:一个使用 OpenGL 上下文创建窗口的多平台库。zlib官网
  • libao:一个有多种输出的跨平台音频库。GNU GPL2.1及更高版本。官网
  • RetroArch:libretro 的参考前端。GNU GPL3官网
  • SDL:一个跨平台库,通过 OpenGL 提供音频,键盘,鼠标,操纵杆和图形硬件的底层访问。zlib官网
  • SDL2:一个跨平台库,通过 OpenGL 提供音频,键盘,鼠标,操纵杆和图形硬件的底层访问。这是最新版本。zlib官网

通用编程

  • klib:小且轻量级的常用算法和数据结构实现。Expat官网

图形

GUI

这些具体来说就是控件工具包

JSON

  • Jansson:一个编码,解码和处理 JSON 的 C 库。Expat官网
  • jsmn:一个极简的 JSON 解析器。Expat官网
  • json-c:一个处理 JSON 的库。Expat官网
  • WJElement:高级 JSON 处理库,支持 JSON Schema。任意版本的 LGPL。官网
  • YAJL:一个很快的 JSON 流解析 C 库。ISC官网

学习、参考和指南

下面列出了学习 C 编程的资源,或者跟 C 编程相关的有用的东西。

在线

参考

初级

中级

高级

自学教程

实体书

参考资料

初级

中级

高级

多媒体

  • FFMPEG:一个完整,跨平台的录音,转换和流化视频以及音频的解决方案。GNU LGPL2.1 或更高版本,部分是 GNU GPL2.1 或更高版本。官网
  • GStreamer:一个声音和可视化媒体的框架。GNU LGPL2.1官网
  • lodepng:一个简单的 PNG 图像解码器和编码器,不需要其他依赖。3-clause BSD.官网

网络编程

Web框架

数值计算

  • apophenia:一个用于统计和科学计算的库。GNU GPL2.1官网
  • ATLAS:自动调谐线性代数软件。 3-clause BSD官网
  • BLAS:Basic Linear Algebra Subprograms;提供向量和矩阵操作的一系列操作。BLAS license官网
  • Cuba:一个计算多维的数值积分的库。 GNU LGPLv3官网
  • FFTW:The Fastest Fourier Transform in the West;一个高度优化的快速傅立叶变换例程。GNU GPL2.1 或更高版本。官网
  • FLINT:Fast Library for Number Theory;一个支持算数,多项式,幂级数和矩阵等。GNU GPL2.1 或更高版本。官网
  • GLPK:GNU Linear Programming Kit;一个求解大规模线性规划,混合整数规划和其他相关问题。GNU GPL3 或更高版本。官网
  • GMP:GNU Multple Precision Arithmetic Library;一个支持任意精度计算的库。双重许可 GNU GPL2.1GNU LGPLv3官网
  • GNU MPC:一个支持复杂数字计算的库。GNU LGPL3 或更高版本。官网
  • GNU MPFR:一个支持任意精度的浮点数计算库。GNU LGPL3 或更高版本(大多数最近版本),GNU LGPL2.1 或更高版本(2.4.x 之前)。官网
  • GNU MPRIA:一个支持多精度合理区间运算的可扩展数学库。GNU GPL3 或更高版本。官网
  • GSL:The GNU Scientific Library;一个精确的数值计算库。GNU GPL3官网
  • KISS FFT:一个非常快的傅里叶变换库。3-clause BSD官网
  • LAPACKE:一个 LAPACK 的 C 接口。3-clause BSD官网
  • PARI/GP:一个数论的计算机代数系统,包括 C 编译器。GNU GPL2.1 或更高版本。官网
  • PETSc:一系列数据结构和例程,用于计算由偏微分方程建模的应用程序的可扩展并行解。FreeBSD官网
  • SLEPc:一个在并行计算机中的解决大型,稀疏特征值问题的软件库。LGPL3官网
  • Yeppp!:非常快,SIMD 优化的数学库。 3-clause BSD官网

并行编程

  • cchan:一个线程间通信通道构建的小型库。公共领域。官网
  • ck:并发原语,安全内存回收机制和非阻塞数据结构。FreeBSD官网
  • mill:用 C 写成的 Go 风格并发。X11官网
  • MPICH:MPI 的另一种实现。MPICH licence官网
  • OpenMP:一组 C 编译指令,使其易于并行化代码。标准(许可不适用)。官网
  • OpenMPI:一个消息传输接口实现。3-clause BSD官网
  • PETSc:一系列数据结构和例程,用于计算由偏微分方程建模的应用程序的可扩展并行解。FreeBSD官网
  • pth:一个非抢占式优先级调度多线程执行的可扩展实现。GNU GPL3 或者更高版本。官网
  • pthreads:POSIX 线程库。标准(没有适用的许可)。官网
  • SLEPc:一个在并行计算机中的解决大型,稀疏特征值问题的软件库。GNU LGPL3官网
  • TinyCThread:一个可扩展,小型的 C11 标准线程 API 实现。zlib官网

正则表达式

有些人遇到问题时就会想:“啊,我知道了,我可以使用正则表达式”。于是现在他们有了两个问题。- Jamie Zawinski。

序列化

  • c-capnproto:一个 Cap'n Proto 序列化协议的实现。 Expat官网
  • cmp:一个 MessagePack 序列化协议的实现。 Expat官网
  • libavro:一个 Avro 数据序列化系统的 C 实现。Apache2.0官网
  • mpack:另一个 MessagePack 序列化协议的实现。Expat官网
  • protobuf-c:一个 Google Protocol Buffer 的 C 实现。FreeBSD官网
  • xdr:External Data Representation;数据序列化标准。标准(没有可用许可)。官网

源码集锦

下面包含了一些小型源码集合。如果你想要大型且成熟的,看《框架》那一节。

  • CCAN:模仿 Perl 的 CPAN,这是一个大的实用 C 代码集合。完整的列表在 这里。多种许可(所有都是免费软件)。官网
  • clib:一个 C 软件包管理器,配备了一堆自己的库。 Expat官网
  • gnulib:通用 GNU 代码的集合。多种许可证,全部免费。官网
  • libdjb:做各种事情的库的集合。(显然)公共领域。官网

标准库

下面包括了标准 C 库。

  • Bionic:谷歌为 Android 开发的 C 标准库。3-clause BSD官网
  • dietlibc:标准 C 库,可能是最小的二进制文件。GNU GPL2.1官网
  • glibc:GNU C 库。一个 C 标准库的实现。 GNU LGPL2.1官网
  • musl:标准 C 库,兼容 POSIX 2008 和 C11,为静态链接设计。Expat官网

字符串处理

测试工具

  • CHEAT:一个非常简单的单元测试框架。FreeBSD官网
  • Check:一个 C 的单元测试框架。GNU LGPL2.1官网
  • CMock:一个 C 的 mock/stub 生成器。官网
  • cmocka:一个支持 mock 对象的单元测试框架。Apache2.0官网
  • Criterion:一个 KISS 风格,非侵入式的 C 测试框架。Expat官网
  • CUnit:另一个 C 的单元测试框架。GNU LGPL2.0官网
  • minunit:极小的 C 单元测试框架。Expat官网
  • Unity:一个简单的 C 单元测试框架。 Expat官网

文本编辑器扩展

在几乎任何像样的文本编辑器支持 C 之际,有一些扩展,让编辑器更加令人愉快。下面是根据编辑器分目录的。

Emacs

  • CEDET:Collection of Emacs Development Environment Tools;给 Emacs 提供一种类似 IDE 的特点,是内建的。GNU GPL3 或更高版本。官网
  • Flycheck:现代语法检查。对于 C,它可以使用 GCC 或者 Clang 作为后端。GNU GPL3 或更高版本。官网
  • Yasnippet:一个模板系统,支持 C 的通用代码片段。GNU GPL3 或更高版本。官网

Vim

工具

下面是实用的程序列表,包括了帮助你编写和调试 C 代码的库或者编译器,不包括编辑器。

  • adlint:一个静态分析器。支持完全的 C89 标准和部分 C99 标准。GNU GPL3 或更高版本。官网
  • Artistic Style:一个支持 C 的小而快的自动化代码格式化工具。GNU LGPL3官网
  • address-sanitizer:一个很快的内存错误探测器。Apache2.0官网
  • biicode:一个现代的 C 依赖管理器。Expat官网
  • c:在命令行中编译和执行 C 脚本,也支持 shebang。 Expat官网
  • c99sh:用 hash-bang 运行 C 文件。FreeBSD官网
  • CBMC:C Bounded Model Checker;一个检查数组边界,指针安全和用户自定义断言的工具。Original BSD官网
  • cdecl:一个在线服务,能够把 C 的声明翻译成英文,反向也可以。公共领域。官网
  • cinclude2dot:在 C 项目中使用 Graphviz 的图像包含依赖。任官网 GNU GPL 版本(根据文件中的要求)官网
  • Complexity:一个测量 C 代码复杂性的工具。GNU GPL3 或更高版本。官网
  • DDD:各种命令行调试器的图形前端。GNU GPL3 或更高版本。官网
  • fab:让每次构建都最优的构建系统。GNU GPL3官网
  • GDB:The GNU Project debugger;一个 C 调试器。GNU GPL3 或更高版本。官网
  • Glade:一个让 TK+ GUIs 开发更快的 RAD 工具。GNU GPL2.1官网
  • GMSL:GNU Make Standard Library;一个 GNU Make 额外功能的集合。3-clause BSD官网
  • GNU Global:一个 C 的源码标签工具。GNU GPL3官网 Global
  • gprof:一个性能分析工具。GNU binutils 的一部分。GNU GPL3 或更高版本。官网
  • Highlight:把源码转化为高亮的格式化文本。GNU GPL3官网
  • include-what-you-use:帮助程序员发现不必要的包含和提供解决他们的建议。基于 LLVM/Clang(只能与它一起工作)。NCSA官网
  • indent:自动格式化 C 代码,让它更容易阅读。也能把一种风格的代码转化为另一种。GNU GPL3 或更高版本。官网
  • Make:一个控制程序的可执行和其他非代码文件的生成的工具。GNU GPL3 或更高版本(链接到 GNU 的实现)。官网
  • qo:无需分开的配置文件的构建系统。Expat官网
  • rr:记录非确定执行来允许可确定调试的调试器。FreeBSD官网
  • tup:一个很快,基于文件,跨平台的构建系统。GNU GPL2.1官网
  • unifdef:移除 #ifdef 和 #if 指令包含的文本,不会改变文件的其他部分。3-clause BSDFreeBSD官网
  • Valgrind:各种动态分析工具,包括一个内存泄漏检测工具。GNU GPL2.1官网

其他工具

下面是包罗万象的目录,主要是那些不适合放在其他目录的东西。

  • ApeTagLibs:APEv2 标签的 C 库。Expat官网
  • bfd:处理二进制对象文件的库。GNU binutils 的一部分。GNU GPL3 或更高版本。官网
  • ccv:基于C语言、带缓存机制的现代计算机视觉核心库。 3-clause BSD官网
  • cf4ocl:The C Framework for OpenCL;一个跨平台面向对象框架,用于开发和用基准问题测试 OpenCL 项目。GNU LGPL3(库), GNU GPL3(其他代码)。官网
  • CommonMark:CommonMark 规范的 C 实现。Variety of licenses, all free官网
  • CException:异常的 C 实现。Expat官网
  • docopt.c:命令行选项解析器的 C 实现。Expat官网
  • dyncall:另一个外部函数接口库。Expat官网
  • FANN:Fast Artifical Neural Network library;一个神经网络的实现。GNU GPL2.1官网
  • Firm:一个 C 库,提供了基于图像中间表示,优化和适合编译器的汇编代码生成。配备了 C 的前端例子,使用相同的许可。GNU LGPLv2.1官网
  • gjrand:随机数字生成的例程库。GNU GPL2.1 或者 GNU GPLv3(用户的选择)。官网
  • GNU FreeIPMI:一个带内和带外的 IPMI 实现。GNU GPL3官网 FreeIPMI
  • GNU gperf:一个完美的哈希函数生成器,提供一系列的字符串。输出 C 代码。GNU GPL3 或更高版本。官网
  • GNU Libffcall:一个构建外部函数接口库的集合。GNU GPL3 或更高版本。官网
  • gperftools:一系列测量和提高性能的实用工具集合。3-clause BSD官网
  • hammer:二进制格式的解析器组合。GPL2.1.官网
  • Hans Boehm GC:C 的垃圾收集器?如果我用了不要介意。多种许可证,完全免费。官网
  • huffandpuff:一个极小的哈夫曼编码器和解码器。公共领域。官网
  • iniparser:一个 .ini 文件的解析器。Expat官网
  • jemalloc:一个 malloc 实现,着重于段错误的避免和可扩展并发支持。FreeBSD官网
  • jwHash:一个很快的哈希表实现。Apache2.0官网
  • kdtree:KD-trees 的简单库。3-clause BSD官网
  • Kitsune:高效,通用的框架,用于软件的动态升级。 GNU LGPL3 或更高版本。官网
  • libavl:一个包括各种自平衡二叉树的库。GNU GPL3 或更高版本。官网
  • libbson:BSON 实用库。Apache2.0官网
  • libCello:引入高级语言给 C 的库。官网
  • libcox:一个运行跨平台系统调用和跨系统标准工具的库。FreeBSD官网
  • libffi:轻量级的外部函数接口库。Expat官网
  • libgit2:Git 的纯 C 实现。GNU GPL2 only, with a linking exception官网
  • libimobiledevice:一个跨平台协议库,用于与 iThings 通信。GNU LGPLv2.1 或更高版本(库),GNU GPL2.1 或更高版本(工具)。官网
  • libmpv:音乐播放库。编译的时候加入 ./waf configure --disable-cplayer --enable-libmpv-shared 来避免生成音乐播放器。GNU GPL2.1 或更高版本。官网
  • libnfc:一个平台独立的 NFC 库。GNU LGPL3官网
  • libPhenom:事件框架,用于构建高扩展和高性能系统。Apache2.0官网GitHub
  • libsoundio:跨平台,实时音频输入输出的库,有很多种后端。Expat官网
  • libucl:通用配置库解析器。FreeBSD官网
  • libudp:一个统一设计模式的 C 实现。GNU GPL3 或更高版本。官网
  • libuv:跨平台异步 I/O。Expat官网
  • libYAML:一个 YAML 1.1 解析器和发射器。 Expat官网
  • lzo:一个很快的数据压缩库。GNU GPL2.1官网
  • mpc:解析器组合库。FreeBSD官网
  • ncurses:彩色的终端 UI 库。GNU GPL3 或更高版本。官网
  • nope.c:一个基于 C 语言,超级轻量级的软件平台,用于可扩展服务端和网络应用的开发(想想 C 程序员的 nodejs)。官网
  • pbc:一个协议缓冲库。Expat官网
  • rabbitmq-c:RabbitMQ 的客户端库。Expat官网
  • Ragel:为编译C的状态机的DSL。GNU GPL2.1官网
  • uthash:哈希表实现,允许已经存在的数据结构很容易地存在哈希表里面。1-clause BSD官网
  • Viola:libCello 的简化版本。Expat官网
  • zlib:一个相当漂亮却精致不张扬的压缩库。3-clause BSD官网
  • Sundown:一个用C编写的符合标准的、快速的、安全的源码解析器。官网

XML

“XML 是垃圾。真的,没有任何借口。XML 对人类不友好的,甚至对于电脑来说也是一场灾难。根官网 -Linus Torvalds

其他资源

有影响力的书

具有广泛影响且值得阅读的 C 语言经典书籍。

  • 待补充

知名网站/博客

值得关注的 C 语言技术站点和博客。

中文

  • 待补充

英文

  • 待补充

微信公众号

  • CPP开发者:专注分享 C/C++ 开发相关的技术文章和工具资源。

转自:https://github.com/jobbole/awesome-c-cn

有一些学习Python的同学,安装PyCharm后不知道怎么激活,或者总是激活不成功,特此写一篇文章分享一下

激活之前需要先修改hosts文件,在里面增加如下一条代码:

0.0.0.0 account.jetbrains.com

Linux中路径/etc/hosts,默认为只读文件,需要运行 sudo vim hosts 输入密码后进入修改。
Windows中路径C:WindowsSystem32driversetchosts,直接用记事本打开就可以编辑。

完成以上步骤后,选择Activation code激活,粘贴一下代码后点击确认即可激活,亲测有效

EB101IWSWD-eyJsaWNlbnNlSWQiOiJFQjEwMUlXU1dEIiwibGljZW5zZWVOYW1lIjoibGFuIHl1IiwiYXNzaWduZWVOYW1lIjoiIiwiYXNzaWduZWVFbWFpbCI6IiIsImxpY2Vuc2VSZXN0cmljdGlvbiI6IkZvciBlZHVjYXRpb25hbCB1c2Ugb25seSIsImNoZWNrQ29uY3VycmVudFVzZSI6ZmFsc2UsInByb2R1Y3RzIjpbeyJjb2RlIjoiSUkiLCJwYWlkVXBUbyI6IjIwMTgtMTAtMTQifSx7ImNvZGUiOiJSUzAiLCJwYWlkVXBUbyI6IjIwMTgtMTAtMTQifSx7ImNvZGUiOiJXUyIsInBhaWRVcFRvIjoiMjAxOC0xMC0xNCJ9LHsiY29kZSI6IlJEIiwicGFpZFVwVG8iOiIyMDE4LTEwLTE0In0seyJjb2RlIjoiUkMiLCJwYWlkVXBUbyI6IjIwMTgtMTAtMTQifSx7ImNvZGUiOiJEQyIsInBhaWRVcFRvIjoiMjAxOC0xMC0xNCJ9LHsiY29kZSI6IkRCIiwicGFpZFVwVG8iOiIyMDE4LTEwLTE0In0seyJjb2RlIjoiUk0iLCJwYWlkVXBUbyI6IjIwMTgtMTAtMTQifSx7ImNvZGUiOiJETSIsInBhaWRVcFRvIjoiMjAxOC0xMC0xNCJ9LHsiY29kZSI6IkFDIiwicGFpZFVwVG8iOiIyMDE4LTEwLTE0In0seyJjb2RlIjoiRFBOIiwicGFpZFVwVG8iOiIyMDE4LTEwLTE0In0seyJjb2RlIjoiUFMiLCJwYWlkVXBUbyI6IjIwMTgtMTAtMTQifSx7ImNvZGUiOiJDTCIsInBhaWRVcFRvIjoiMjAxOC0xMC0xNCJ9LHsiY29kZSI6IlBDIiwicGFpZFVwVG8iOiIyMDE4LTEwLTE0In0seyJjb2RlIjoiUlNVIiwicGFpZFVwVG8iOiIyMDE4LTEwLTE0In1dLCJoYXNoIjoiNjk0NDAzMi8wIiwiZ3JhY2VQZXJpb2REYXlzIjowLCJhdXRvUHJvbG9uZ2F0ZWQiOmZhbHNlLCJpc0F1dG9Qcm9sb25nYXRlZCI6ZmFsc2V9-Gbb7jeR8JWOVxdUFaXfJzVU/O7c7xHQyaidCnhYLp7v32zdeXiHUU7vlrrm5y9ZX0lmQk3plCCsW+phrC9gGAPd6WDKhkal10qVNg0larCR2tQ3u8jfv1t2JAvWrMOJfFG9kKsJuw1P4TozZ/E7Qvj1cupf/rldhoOmaXMyABxNN1af1RV3bVhe4FFZe0p7xlIJF/ctZkFK62HYmh8V3AyhUNTzrvK2k+t/tlDJz2LnW7nYttBLHld8LabPlEEjpTHswhzlthzhVqALIgvF0uNbIJ5Uwpb7NqR4U/2ob0Z+FIcRpFUIAHEAw+RLGwkCge5DyZKfx+RoRJ/In4q/UpA==-MIIEPjCCAiagAwIBAgIBBTANBgkqhkiG9w0BAQsFADAYMRYwFAYDVQQDDA1KZXRQcm9maWxlIENBMB4XDTE1MTEwMjA4MjE0OFoXDTE4MTEwMTA4MjE0OFowETEPMA0GA1UEAwwGcHJvZDN5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxcQkq+zdxlR2mmRYBPzGbUNdMN6OaXiXzxIWtMEkrJMO/5oUfQJbLLuMSMK0QHFmaI37WShyxZcfRCidwXjot4zmNBKnlyHodDij/78TmVqFl8nOeD5+07B8VEaIu7c3E1N+e1doC6wht4I4+IEmtsPAdoaj5WCQVQbrI8KeT8M9VcBIWX7fD0fhexfg3ZRt0xqwMcXGNp3DdJHiO0rCdU+Itv7EmtnSVq9jBG1usMSFvMowR25mju2JcPFp1+I4ZI+FqgR8gyG8oiNDyNEoAbsR3lOpI7grUYSvkB/xVy/VoklPCK2h0f0GJxFjnye8NT1PAywoyl7RmiAVRE/EKwIDAQABo4GZMIGWMAkGA1UdEwQCMAAwHQYDVR0OBBYEFGEpG9oZGcfLMGNBkY7SgHiMGgTcMEgGA1UdIwRBMD+AFKOetkhnQhI2Qb1t4Lm0oFKLl/GzoRykGjAYMRYwFAYDVQQDDA1KZXRQcm9maWxlIENBggkA0myxg7KDeeEwEwYDVR0lBAwwCgYIKwYBBQUHAwEwCwYDVR0PBAQDAgWgMA0GCSqGSIb3DQEBCwUAA4ICAQC9WZuYgQedSuOc5TOUSrRigMw4/+wuC5EtZBfvdl4HT/8vzMW/oUlIP4YCvA0XKyBaCJ2iX+ZCDKoPfiYXiaSiH+HxAPV6J79vvouxKrWg2XV6ShFtPLP+0gPdGq3x9R3+kJbmAm8w+FOdlWqAfJrLvpzMGNeDU14YGXiZ9bVzmIQbwrBA+c/F4tlK/DV07dsNExihqFoibnqDiVNTGombaU2dDup2gwKdL81ua8EIcGNExHe82kjF4zwfadHk3bQVvbfdAwxcDy4xBjs3L4raPLU3yenSzr/OEur1+jfOxnQSmEcMXKXgrAQ9U55gwjcOFKrgOxEdek/Sk1VfOjvS+nuM4eyEruFMfaZHzoQiuw4IqgGc45ohFH0UUyjYcuFxxDSU9lMCv8qdHKm+wnPRb0l9l5vXsCBDuhAGYD6ss+Ga+aDY6f/qXZuUCEUOH3QUNbbCUlviSz6+GiRnt1kA9N2Qachl+2yBfaqUqr8h7Z2gsx5LcIf5kYNsqJ0GavXTVyWh7PYiKX4bs354ZQLUwwa/cG++2+wNWP+HtBhVxMRNTdVhSm38AknZlD+PTAsWGu9GyLmhti2EnVwGybSD2Dxmhxk3IPCkhKAK+pl0eWYGZWG3tJ9mZ7SowcXLWDFAk0lRJnKGFMTggrWjV8GYpw5bq23VmIqqDLgkNzuoog==

按步骤操作有什么问题可以留言或发邮件给我。邮件在个人介绍页

#coding:utf-8


# NO.1
def dispatch_if(operator, x, y):
    if operator == 'add':
        return x + y
    elif operator == 'sub':
        return x - y
    elif operator == 'mul':
        return x * y
    elif operator == 'div':
        return x / y
    else:
        return None


def dispatch_dict(operator, x, y):
    return {
        'add': lambda: x + y,
        'sub': lambda: x - y,
        'mul': lambda: x * y,
        'div': lambda: x / y,
    }.get(operator, lambda: None)()


print(dispatch_if('sub', 5, 9))
print(dispatch_dict('mul', 3, 7))
print(dispatch_if('unknown', 2, 8))
print(dispatch_dict('unknown', 2, 8))


# NO.2
def myfunc(a, b):
    return a + b

funcs = [myfunc]
print(funcs[0])
print(funcs[0](2, 3))


# NO.3
my_mapping = {'a': 23, 'b': 42, 'c': 0xc0ffee}
print(my_mapping)

import json
print(json.dumps(my_mapping, indent=4, sort_keys=True))

# json.dumps({all: 'yup'})


# NO.4
name_for_userid = {
    382: "Alice",
    590: "Bob",
    951: "Dilbert",
}

def greeting(userid):
    return "Hi %s!" % name_for_userid.get(userid, "there")

print(greeting(951))

# NO.5
xs = {'a': 4, 'b': 3, 'c': 2, 'd': 1}

S = (sorted(xs.items(), key=lambda x: x[1]))
print(S)
# Or:

import operator
S = sorted(xs.items(), key=operator.itemgetter(1))
print(S)