- Python漫游数学王国:高等数学、线性代数、数理统计及运筹学
- 毕文斌 毛悦悦编著
- 785字
- 2025-02-25 23:58:46
第1章 Python基础
1.1 Python简介与安装
Python是1989年荷兰人Guido van Rossum为修改ABC语言而发明的一种面向对象的解释型高级编程语言,它的设计优美、清晰、简单。第一个Python编辑器诞生于1991年,当时它已具有了列表、字典、函数、类、异常处理等核心数据类型与机制,以及基于模块的拓展系统。Python特别在意可拓展性,它有丰富和强大的库,能够把其他语言制作的各种模块轻松地连接在一起。因此,Python常被称为“胶水”语言。
2001年,Python软件基金会(Python Software Foundation, PSF)成立于美国Delaware州。基金会的宗旨是:促进、保护和发展Python编程语言,同时支持并辅助Python开发者组成的多样化的国际社区的发展。基于上述宗旨,基金会的主要职责有:开发核心模块与函数,维护Python文档,联络开发者和使用者的社区以及组织会议。Python官方网站为https://www.python.org。
Python是一种跨平台的编程语言,可以运行在多个操作系统中,如Linux系统、Mac OS X系统与Windows系统。要进行Python开发,需要先安装Python解释器,解释器的下载请访问https://www.python.org/downloads/,安装步骤如下。
根据计算机操作系统的需要选择下载安装文件,以Windows系统为例,如图1.1所示。
选择Python,推荐版本3.7.5,如图1.2所示。
选择Windows x86-64 executable installer,如图1.3所示。

图 1.1

图 1.2

图 1.3
选择下载保存路径,如图1.4所示。

图 1.4
下载完成后先在非系统盘(推荐D盘)新建一个文件夹,将其命名为python3.7.5, Python将被安装至这个文件夹中,如图1.5所示。

图 1.5
双击Python 3.7.5安装程序,勾选Add Python 3.7 to PATH复选框,单击Customize installation(自定义安装),如图1.6所示。

图 1.6
在接下来的界面,单击Next按钮,如图1.7所示。

图 1.7
单击Browse按钮,选择安装路径,然后单击Install按钮直至安装结束,如图1.8所示。

图 1.8
下面安装第三方库,打开文件夹,路径如图1.9所示。

图 1.9
选中文件夹路径,如图1.10所示。

图 1.10
在此输入命令“cmd”,按Enter键,如图1.11所示。

图 1.11
输入命令“pip install numpy”,按Enter键,如图1.12所示。

图 1.12
numpy安装结束,如图1.13所示。

图 1.13
输入命令“pip install matplotlib”,按Enter键,如图1.14所示。
matplotlib安装结束,如图1.15所示。
查看安装好的库,如图1.16所示。

图 1.14

图 1.15

图 1.16
依次输入以下命令,获得本书需要的库。
