Skip to Content
Python入门指南, 3rd Edition
book

Python入门指南, 3rd Edition

by Bill Lubanovic
September 2025
Intermediate to advanced
660 pages
7h 15m
Chinese
O'Reilly Media, Inc.
Content preview from Python入门指南, 3rd Edition

第 13 章 开发环境 开发环境

本作品已使用人工智能进行翻译。欢迎您提供反馈和意见:translation-feedback@oreilly.com

总想穿越时空,与年轻时的自己一决高下? 软件开发就是你的理想职业!

埃利奥特-罗

本书第一部分主要描述了 Python 编程语言的语法。到目前为止,你真正需要的计算机工具只有这些:

  • 一个文本编辑器,用来编写 Python 代码

  • 一个终端,用来运行 Python 程序

本章主要介绍 Python 开发的艺术和科学,并提出了 "最佳实践 "建议,包括其他工具、概念和组织工作的方法。 吸收这些内容,你也可以成为一名持证的 Python 达人:

  • 如何查找、安装和更新 Python 代码

  • 集成开发环境--基本文本编辑器和终端之外的工具

  • 使用 Git 进行源码控制

查找 Python 代码

当 您需要开发代码时,最快的解决办法就是从允许的源代码中窃取代码。

Python标准库既宽又深,而且大部分都很清晰。 里面的所有东西都可以免费使用。 潜入其中,寻找那些珍珠。

就像各种体育运动的名人堂一样,一个模块进入标准库也需要时间。 新的软件包不断出现;在本书中,我重点介绍了一些新的软件包或做得更好的老软件包。 Python 的广告说它包含电池,但您可能需要一种新的电池。

那么,在标准库之外,您应该到 寻找好的 Python 代码呢?

  • 要查找的第一个地方是Python 软件包索引 (PyPI)。 该网站的前身是根据 Monty Python 的一个短剧而命名的奶酪店,它不断更新 Python 软件包,在我写这篇文章的时候已经超过 600,000 个。当您使用pip 时(见下一节),它会搜索 PyPI。PyPI 主页面显示最近添加的软件包。您也可以在 PyPI 主页中间的搜索框中输入内容进行直接搜索。例如,genealogy 得到 69 个匹配,movies 得到 1,814 个匹配。另一个流行的软件仓库是 GitHub。在那里可以查看所有 Python 软件包(按 GitHub 星级排序,星级表示流行程度)。

  • 另一个流行的仓库是 GitHub。 在那里可以查看所有Python 软件包(按 GitHub星级排序,星级表示流行程度)或当前流行的软件包。

  • "流行 Python Recipes "有四千多个简短的 Python 程序,涉及各个主题。

安装软件包

有很多安装 Python 软件包的方法:

  • 能用 pip 就用 pip,这是目前最常用的方法。 你可以用 pip 安装大部分可能遇到的 Python 软件包。

  • 使用 Pipenv,它结合了 pip 和 virtualenv。

  • 或者试试 Poetry,它试图改进 Pipenv。

  • 如果你经常使用 Python 科学软件包,Conda 值得一试。

  • 还有一个:uv 是一个更新的工具,它的目标是超越所有其他工具。

让我们来看看所有这些方法。

使用 Pip

Python 打包有其局限性。早期的安装工具easy_installpip 取代, 由 Ian Bicking 编写。

这两个工具都没有出现在标准 Python 安装程序中。因此,如果您应该使用pip 来安装软件包,那么您从哪里得到pip 呢?从 Python 3.4 开始,pip 最终将与 Python 的其它部分一起包含,以避免这种生存危机。如果您使用的是 Python 3 的早期版本,并且没有pip ,您可以通过pip 文档站点获得它。

pip ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

生成式人工智能设计模式

生成式人工智能设计模式

Valliappa Lakshmanan, Hannes Hapke

Publisher Resources

ISBN: 9798341668898