Python 简明教程
Python - Application Areas
Python 是一种通用编程语言。它适用于各种软件应用程序的开发。在过去几年中,Python 已成为开发人员在以下应用程序领域的首选语言:
Python is a general-purpose programming language. It is suitable for the development of a wide range of software applications. Over the last few years Python has been the preferred language of choice for developers in the following application areas −
让我们详细了解这些应用程序领域:
Let’s look into these application areas in more detail:
Data Science
Python 最近在流行榜上的惊人崛起很大程度上归功于其数据科学库。Python 已成为数据科学家的必备技能。如今,实时 Web 应用程序、移动应用程序和其他设备会生成大量数据。Python 的数据科学库帮助公司从这些数据中生成业务见解。
Python’s recent meteoric rise in the popularity charts is largely due to its Data science libraries. Python has become an essential skill for data scientists. Today, real time web applications, mobile applications and other devices generate huge amount of data. Python’s data science libraries help companies generate business insights from this data.
像 NumPy 、 Pandas 和 Matplotlib 这样的库被广泛用于将数学算法应用到数据并生成 visualizations 。商业和社区 Python 发行版(如 Anaconda 和 ActiveState)捆绑了数据科学所需的所有必需库。
Libraries like NumPy, Pandas, and Matplotlib are extensively used to apply mathematical algorithms to the data and generate visualizations. Commercial and community Python distributions like Anaconda and ActiveState bundle all the essential libraries required for data science.
Machine Learning
像 Scikit-learn 和 TensorFlow 这样的 Python 库有助于根据过去数据构建模型,用于预测客户满意度、股票预期价值等趋势。 Machine learning 应用包括(但不限于)医疗诊断、统计套利、篮子分析、销售预测等。
Python libraries such as Scikit-learn and TensorFlow help in building models for prediction of trends like customer satisfaction, projected values of stocks etc. based upon the past data. Machine learning applications include (but not restricted to) medical diagnosis, statistical arbitrage, basket analysis, sales prediction etc.
Web Development
Python 的 Web 框架促进了快速的 Web 应用程序开发。 Django 、 Pyramid 、 Flask 在 Web 开发人员社区中非常流行。等等使得开发和部署从简单到复杂的各种 Web 应用程序变得非常容易。
Python’s web frameworks facilitate rapid web application development. Django, Pyramid, Flask are very popular among the web developer community. etc. make it very easy to develop and deploy simple as well as complex web applications.
最新版本的 Python 提供异步编程支持。现代 Web 框架利用此功能开发快速且高性能的 Web 应用程序和 API。
Latest versions of Python provide asynchronous programming support. Modern web frameworks leverage this feature to develop fast and high performance web apps and APIs.
Computer Vision and Image processing
OpenCV 是一个广泛流行的库,用于捕获和处理图像。图像处理算法从图像中提取信息,重建图像和视频数据。计算机视觉使用图像处理进行人脸检测和模式识别。OpenCV 是一个 C++ 库。其 Python 端口因其快速开发特性而被广泛使用。
OpenCV is a widely popular library for capturing and processing images. Image processing algorithms extract information from images, reconstruct image and video data. Computer Vision uses image processing for face detection and pattern recognition. OpenCV is a C++ library. Its Python port is extensively used because of its rapid development feature.
计算机视觉的一些应用领域包括 robotics 、工业监控、自动化和 biometrics 等。
Some of the application areas of computer vision are robotics, industrial surveillance, automation, and biometrics etc.
Embedded Systems and IoT
Micropython ( https://micropython.org/ )是一个轻量级版本,特别适用于像 Arduino 这样的微控制器。许多自动化产品、机器人 IoT 和信息亭应用程序都是围绕 Arduino 构建的,并使用 Micropython 进行编程。 Raspberry Pi 也是一种非常流行的低成本单板计算机,用于此类应用程序。
Micropython (https://micropython.org/), a lightweight version especially for microcontrollers like Arduino. Many automation products, robotics, IoT, and kiosk applications are built around Arduino and programmed with Micropython. Raspberry Pi is also very popular alow cost single board computer used for these type of applications.
Job Scheduling and Automation
Python 在自动化 CRON(按时执行命令)作业中找到了它的第一个应用。某些任务(如定期数据备份)可以用 Python 脚本编写,计划由操作系统计划程序自动调用。
Python found one of its first applications in automating CRON (Command Run ON) jobs. Certain tasks like periodic data backups, can be written in Python scripts scheduled to be invoked automatically by operating system scheduler.
许多软件产品(如 Maya)嵌入了 Python API,用于编写自动化脚本(类似于 Excel 微控件)。
Many software products like Maya embed Python API for writing automation scripts (something similar to Excel micros).
Desktop GUI Applications
Python 是构建符合人体工程学、美观且用户友好的桌面 GUI 应用程序的理想选择。尽管几个图形库使用 C/C++ 构建,但它们已被移植到 Python。流行的 Qt 图形工具包在 Python 中作为一个 PyQt 包提供。类似地,WxWidgets 已被移植到 Python 中,成为 WxPython 。Python 的内置 GUI 包 TKinter 是一个 Python 接口,可用于 Tk 图形工具包。
Python is a great option for building ergonomic, attractive, and user-friendly desktop GUI applications. Several graphics libraries, though built in C/C++, have been ported to Python. The popular Qt graphics toolkit is available as a PyQt package in Python. Similarly, WxWidgets has been ported to Python as WxPython. Python’s built-in GUI package, TKinter is a Python interface to the Tk Graphics toolkit.
这有一份精选的 Python GUI 库列表:
Here is a select list of Python GUI libraries:
-
Tkinter − Tkinter is the Python interface to the Tk GUI toolkit shipped with Python’s standard library.
-
wxPython − This is the Python interface for the wxWidgets GUI toolkit. BitTorrent Client application has been built with wxPython functionality.
-
PyQt – Qt is one of the most popular GUI toolkits. It has been ported to Python as a PyQt5 package. Notable desktop GUI apps that use PyQt include QGIS, Spyder IDE, Calibre Ebook Manager, etc.
-
PyGTK − PyGTK is a set of wrappers written in Python and C for GTK + GUI library. The complete PyGTK tutorial is available here.
-
PySimpleGUI − PySimpleGui is an open-source, cross-platform GUI library for Python. It aims to provide a uniform API for creating desktop GUIs based on Python’s Tkinter, PySide, and WxPython toolkits.
-
Jython − Jython is a Python port for Java, which gives Python scripts seamless access to the Java GUI libraries on the local machine.
Console-based Applications
Python 通常用于构建 CLI(命令行界面)应用程序。此类脚本可用于运行计划的 CRON 作业,例如执行数据库备份等。有很多 Python 库可以解析命令行参数。argparse 库与 Python 的标准库捆绑在一起。您可以使用 Click(Flask 框架的一部分)和 Typer(包含在 FastAPI 框架中)为各个框架构建的基于 Web 的应用程序构建控制台界面。Textual 是一个快速开发框架,用于构建同时在终端和浏览器中运行的应用程序。
Python is often employed to build CLI (command-line interface) applications. Such scripts can be used to run scheduled CRON jobs such as taking database backups etc. There are many Python libraries that parse the command line arguments. The argparse library comes bundled with Python’s standard library. You can use Click (part of Flask framework) and Typer (included in FastAPI framework) to build console interfaces to the web-based applications built by the respective frameworks. Textual is a rapid development framework to build apps that run inside a terminal as well as browsers.
CAD Applications
CAD 工程师可以利用 Python 的多功能性来自动执行重复性任务,例如绘制形状和生成报告。
CAD engineers can take advantage of Python’s versatility to automate repetitive tasks such as drawing shapes and generating reports.
Autodesk Fusion 360 是一个流行的 CAD 软件,它有一个 Python API,允许用户自动执行任务并创建自定义工具。同样,SolidWorks 有一个内置的 Python shell,允许用户在该软件内运行 Python 脚本。
Autodesk Fusion 360 is a popular CAD software, which has a Python API that allows users to automate tasks and create custom tools. Similarly, SolidWorks has a built-in Python shell that allows users to run Python scripts inside the software.
CATIA 是另一款非常流行的 CAD 软件。除了 VBScript 外,还可以使用某些第三方 Python 库来控制 CATIA。
CATIA is another very popular CAD software. Along with a VBScript, certain third-party Python libraries that can be used to control CATIA.
Game Development
一些流行的游戏应用程序是使用 Python 构建的。示例包括 BattleField2、模拟人生 4、坦克世界、加勒比海盗等。这些应用程序都使用以下 Python 库之一构建。
Some popular gaming apps have been built with Python. Examples include BattleField2, The Sims 4, World of Tanks, Pirates of the Caribbean, and more. These apps are built with one of the following Python libraries.
Pygame 是用于构建引人入胜的电脑游戏的最流行的 Python 库之一。Pygame 是一个开源 Python 库,用于制作多媒体应用程序,例如构建在出色的 SDL 库之上的游戏。它是一个跨平台库,这意味着您可以构建可以在任何操作系统平台上运行的游戏。
Pygame is one of the most popular Python libraries used to build engaging computer games. Pygame is an open-source Python library for making multimedia applications like games built on top of the excellent SDL library. It is a cross-platform library, which means you can build a game that can run on any operating system platform.
另一个库 Kivy 也被广泛用于构建桌面游戏和基于移动设备的游戏。Kivy 具有多点触控界面。它是一个开源跨平台 Python 库,用于快速开发游戏应用程序。Kivy 可在 Linux、Windows、OS X、Android、iOS 和 Raspberry Pi 上运行。
Another library Kivy is also widely used to build desktop as well as mobile-based games. Kivy has a multi-touch interface. It is an open-source and cross-platform Python library for rapid development of game applications. Kivy runs on Linux, Windows, OS X, Android, iOS, and Raspberry Pi.
PyKyra 库基于 SDL(软件和文档本地化)和 Kyra 引擎。它是最快的一些游戏开发框架。PyKyra 支持 MPEG、MP3、Ogg Vorbis、Wav 等多媒体格式。
PyKyra library is based on both SDL (Software and Documentation Localisation) and the Kyra engine. It is one of the fastest game development frameworks. PyKyra supports MPEG , MP3, Ogg Vorbis, Wav, etc., multimedia formats.