diff --git a/project01/01.Python环境部署.md b/project01/01.Python环境部署.md index 1b55aeb..9971aac 100644 --- a/project01/01.Python环境部署.md +++ b/project01/01.Python环境部署.md @@ -1,12 +1,12 @@ -# Python介绍 +# Python基础 -> Life is short, I need python(人生苦短,我用python!) +Life is short, I need python(人生苦短,我用python!) ## Python起源 Python的作者是著名的"**龟叔**"Guido van Rossum(吉多.范罗苏姆),1989年,龟叔为了打发无聊的圣诞节,决心开发一个新的**解释程序**,作为ABC语言的一种继承。于是便开始编写Python语言。 -image-20240902103540169 +![image-20240902103540169](01.Python环境部署/image-20240902103540169-1757675057864-1.png) **ABC**是由吉多参加设计的一种教学语言,就吉多本人看来,ABC这种语言非常优美和强大,是**专门为非专业程序员设计的**。但是ABC语言并没有成功。**Guido**本人看来,**ABC**失败的原因是高级语言为时过早,并且平台迁移能力弱,难以添加新功能,仅仅专注于编程初学者,没有把有经验的编程人员纳入其中,在**Python**中解决了这些问题,让拓展模块的编写非常容易,并且可以在多平台进行运行.... @@ -25,11 +25,9 @@ Python的意思是蟒蛇,是取自英国20世纪70年代首播的电视喜剧 - [TIOBE Index](https://www.tiobe.com/tiobe-index/) - [PYPL Index](https://pypl.github.io/PYPL.html) -image-20240920215125704 - ## Python应用领域 -**人工智能** +**人工智能** Python 是人工智能和机器学习领域的首选语言,主要得益于其简洁的语法和丰富的科学计算库。以下是几种典型的 Python 库: @@ -38,26 +36,26 @@ Python 是人工智能和机器学习领域的首选语言,主要得益于其 - **Matplotlib**:强大的绘图库,可以生成各种图形,包括线图、散点图、柱状图等,常用于数据可视化。 - **TensorFlow**:由 Google 开发的开源深度学习框架,广泛用于构建和训练神经网络。 -**云计算** +**云计算** Python 是云计算领域最火的语言之一,广泛用于构建和管理云基础设施。Python 的简洁性和可读性使得它成为开发云服务、自动化任务、数据处理脚本的理想选择。 -**WEB开发** +**WEB开发** Python 拥有众多优秀的 Web 框架,适合快速开发高效、安全的 Web 应用程序。许多大型网站和服务都是用 Python 开发的,例如 YouTube、Dropbox、豆瓣等。以下是几种典型的 Web 框架: - **Django**:一个高层次的 Python Web 框架,鼓励快速开发和简洁、实用的设计,是全栈框架的代表。 - **Flask**:一个轻量级的 Web 框架,强调简单性和灵活性,适合构建小型项目或微服务。 -**系统运维** +**系统运维** Python 是系统运维人员的必备语言。它可以用于编写脚本来自动化任务、管理服务器、处理文件和文本、与操作系统进行交互等。Python 的跨平台性使得它在不同的操作系统上都能有效发挥作用。 -**金融** +**金融** Python 在金融领域特别是量化交易和金融分析方面得到广泛应用。Python 的灵活性和丰富的金融数据分析库,使得它在金融工程领域的使用日益增多,重要性逐年提高。 -**图形界面开发 (GUI)** +**图形界面开发 (GUI)** Python 也可以用于开发桌面应用程序,以下是几种常用的图形界面开发库: @@ -91,139 +89,150 @@ Python 也可以用于开发桌面应用程序,以下是几种常用的图形 ## Python设计哲学 -image-20240902110217569 +![image-20240902110217569](01.Python环境部署/image-20240902110217569-1757675057864-2.png) Python 的设计哲学与其他编程语言相比,有几个显著的不同之处: -1. **可读性优先**: +1. 可读性优先: - Python 强调代码的可读性,力求清晰明了。这与如 C++ 或 Java 等语言相比,后者往往更关注性能或复杂的语法结构。 -2. **简洁性**: +2. 简洁性: - Python 鼓励用较少的代码实现功能,通常会有简化的语法,而像 Java 这样的语言则要求更多的样板代码。 -3. **动态类型**: +3. 动态类型: - Python 是动态类型语言,变量类型在运行时决定,这与静态类型语言(如 C# 和 Java)形成鲜明对比,后者在编译时必须声明变量类型。 -4. **多范式支持**: +4. 多范式支持: - Python 支持多种编程范式(如面向对象、函数式编程),而一些语言则更倾向于某一特定范式,如 Java 主要是面向对象的。 -5. **强大的标准库**: +5. 强大的标准库: - Python 附带了一个丰富的标准库,提供了大量现成的模块和功能,而其他语言可能需要依赖外部库或框架。 -6. **社区和文化**: +6. 社区和文化: - Python 拥有一个积极的社区,强调开放和共享,鼓励用户贡献代码和文档,而其他语言的社区文化可能更加保守或封闭。 -# Python环境部署 +## 安装python -## Python解释器 +- 检查电脑上是否已经存在python环境,在cmd中输入python,如果出现版本,就说明已经装好 -- 打开官网:https://www.python.org/downloads -- 找到对应的版本,这里选择版本3.9.8 +![image-20250908102930699](01.Python环境部署/image-20250908102930699.png) -**3.9.8版本**下载链接:https://www.python.org/ftp/python/3.9.8/python-3.9.8-amd64.exe +- 如果存在其他版本,建议卸载 -image-20240902111134272 +![image-20250908103209461](01.Python环境部署/image-20250908103209461.png) -image-20240902111545070 +- 安装步骤 -打开安装包,添加环境变量,可以选择默认安装或者自定义安装(一般自定义安装主要是修改安装路径) +![image-20250908103038856](01.Python环境部署/image-20250908103038856.png) -image-20240902112236819 +- 开始安装 -image-20240902142136568 +![image-20250908103300961](01.Python环境部署/image-20250908103300961.png) -**注意:**必须勾选上下面的"Add Python 3.9 to PATH"(添加到系统环境变量中) +- 完成安装 -**测试是否安装成功** +![image-20250908103521450](01.Python环境部署/image-20250908103521450.png) -在键盘上按下`win+R`然后在左下弹出窗口中输入`cmd`回车 +## 安装pycharm -在cmd终端中输入python,如果可以看到如下内容,说明python环境安装成功,并且请核对版本号是否与我们安装的一致.... +- 建议卸载旧的 -```bash -C:\Users\test>python -Python 3.9.8 (tags/v3.9.8:bb3fdcf, Nov 5 2021, 20:48:33) [MSC v.1929 64 bit (AMD64)] on win32 -Type "help", "copyright", "credits" or "license" for more information. ->>> -``` +![image-20250908103720353](01.Python环境部署/image-20250908103720353.png) -## Python编辑器 +- 打开安装包 -Python可用的编辑器有很多,因为编辑器只负责编写代码,实际的代码执行还是由我们刚刚安装的解释器进行编译解释。所以编写Python代码对编辑器的要求不是很高。不过,为了便于我们敲代码,我们还是要选择一些更加高级,功能更多的编辑器来使用。这样在编写代码的时候可以事半功倍 +![image-20250908103851450](01.Python环境部署/image-20250908103851450.png) -对于Python而言,最出名,最好用的编辑器就是pycharm了。我们后续学习也主要使用pycharm编辑器。 +- 勾上快捷方式 -### 其他编辑器 +![image-20250908103938229](01.Python环境部署/image-20250908103938229.png) -**以下仅作为了解即可...** +- 开始安装 -1. **vim编辑器** +![image-20250908104000089](01.Python环境部署/image-20250908104000089.png) -Vim(Vi IMproved)是一个高度可配置的文本编辑器,它源自于一个名为Vi的早期Unix编辑器。Vim的设计目标是提供一种高效的方式来编辑文本文件,它广泛应用于程序员和系统管理员中,因为它支持多种编程语言的语法高亮、代码补全、编译和错误跳转等功能。 +- 完成安装 -Vim是一个主要基于命令行的编辑器,几乎所有的操作,如:复制、粘贴、删除等待,都需要通过指令来完成。所以说使用难度相对较高,我们后面的云计算部分会深入学习... +![image-20250908105245692](01.Python环境部署/image-20250908105245692.png) -2. **Sublim Text** +### 激活 -Sublime Text 是一个代码编辑器(Sublime Text 2是收费软件,但可以无限期试用) +- 安装完成后,先不启动,或者先关闭,运行激活脚本,一定要确保pycharm被彻底关闭 -Sublime Text是由程序员Jon Skinner于2008年1月份所开发出来,它最初被设计为一个具有丰富扩展功能的Vim。 +![image-20250908110107975](01.Python环境部署/image-20250908110107975.png) -Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。 +- 运行完成 -还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。 +![image-20250908105511298](01.Python环境部署/image-20250908105511298.png) -Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。 +![image-20250908105532634](01.Python环境部署/image-20250908105532634.png) -下载地址:http://www.sublimetext.com/3 +- 如果出现选择区域,推荐选择未指定,选择不发送共享数据 -image-20240904101732444 +![image-20250908110152211](01.Python环境部署/image-20250908110152211.png) -image-20240902143634827 +- 选择管理订阅 -### Pycharm的安装 +![image-20250908110248322](01.Python环境部署/image-20250908110248322.png) -下载地址:http://www.jetbrains.com/pycharm/download/#section=windows +- 填写激活脚本中的激活码 -因为社区版可能会缺少部分功能,所以直接选择专业版 +![image-20250908110328448](01.Python环境部署/image-20250908110328448.png) -**安装过程:** +- 激活成功 -1. 下载安装包并且安装 -2. 使用Eagleslab提供的补丁工具进行激活 -3. 查看设置-->About +![image-20250908110405537](01.Python环境部署/image-20250908110405537.png) -**上述操作环节较多,认真观看老师的操作~** +## 运行python代码 -image-20240902145526575 +### 新建项目 -## 创建第一个项目 +- 创建新项目 -1. 点击New Project来创建一个项目,项目Name和Location可以自定义 +![image-20250908110806880](01.Python环境部署/image-20250908110806880.png) -image-20240902145711220 +- 创建完成 -2. 在项目名称上右键来创建一个Python File +![image-20250908110841673](01.Python环境部署/image-20250908110841673.png) -image-20240902145939086 +- 进行简单设置,比如修改主题 -3. 编写第一个Python代码 +![image-20250908110950343](01.Python环境部署/image-20250908110950343.png) + +- 更改主题 + +![image-20250908111030150](01.Python环境部署/image-20250908111030150.png) + +- 切换语言包 + +![image-20250908111150143](01.Python环境部署/image-20250908111150143.png) + +- 修改字体大小 + +![image-20250908111555981](01.Python环境部署/image-20250908111555981.png) + +- 关闭ai自动填充 + +![image-20250908111655330](01.Python环境部署/image-20250908111655330.png) + +![image-20250908111746430](01.Python环境部署/image-20250908111746430.png) + +创建demo1 + +![image-20250908111815827](01.Python环境部署/image-20250908111815827.png) ```python print('Hello World!') ``` -然后右键->Run demo.py来运行 +![image-20250908111935788](01.Python环境部署/image-20250908111935788.png) -image-20240902150205122 +然后右键运行 -```bash -# Output -C:\Users\test\PycharmProjects\pythonProject\.venv\Scripts\python.exe C:\Users\test\PycharmProjects\pythonProject\demo.py -hello world +![image](01.Python环境部署/1553917000771-909b5d59-8d4a-4e57-9dfe-95f0ba3a12ee.png) + +运行结果 + +``` +C:\Users\Aaron\AppData\Local\Programs\Python\Python35\python.exe C:/Users/Aaron/Desktop/py/t1.py +Hello World! Process finished with exit code 0 ``` -## Pycharm优化 - -1. 中文支持 -2. 字体大小调节 -3. 主题更改 - -...... \ No newline at end of file +## \ No newline at end of file diff --git a/project01/01.Python环境部署/1553917000771-909b5d59-8d4a-4e57-9dfe-95f0ba3a12ee.png b/project01/01.Python环境部署/1553917000771-909b5d59-8d4a-4e57-9dfe-95f0ba3a12ee.png new file mode 100644 index 0000000..71c066b Binary files /dev/null and b/project01/01.Python环境部署/1553917000771-909b5d59-8d4a-4e57-9dfe-95f0ba3a12ee.png differ diff --git a/project01/01.Python环境部署/image-20240902103540169-1757675057864-1.png b/project01/01.Python环境部署/image-20240902103540169-1757675057864-1.png new file mode 100644 index 0000000..650d408 Binary files /dev/null and b/project01/01.Python环境部署/image-20240902103540169-1757675057864-1.png differ diff --git a/project01/01.Python环境部署/image-20240902110217569-1757675057864-2.png b/project01/01.Python环境部署/image-20240902110217569-1757675057864-2.png new file mode 100644 index 0000000..b8bbb24 Binary files /dev/null and b/project01/01.Python环境部署/image-20240902110217569-1757675057864-2.png differ diff --git a/project01/01.Python环境部署/image-20250908102930699.png b/project01/01.Python环境部署/image-20250908102930699.png new file mode 100644 index 0000000..258d847 Binary files /dev/null and b/project01/01.Python环境部署/image-20250908102930699.png differ diff --git a/project01/01.Python环境部署/image-20250908103038856.png b/project01/01.Python环境部署/image-20250908103038856.png new file mode 100644 index 0000000..9d1eec1 Binary files /dev/null and b/project01/01.Python环境部署/image-20250908103038856.png differ diff --git a/project01/01.Python环境部署/image-20250908103209461.png b/project01/01.Python环境部署/image-20250908103209461.png new file mode 100644 index 0000000..20ab860 Binary files /dev/null and b/project01/01.Python环境部署/image-20250908103209461.png differ diff --git a/project01/01.Python环境部署/image-20250908103300961.png b/project01/01.Python环境部署/image-20250908103300961.png new file mode 100644 index 0000000..5caa710 Binary files /dev/null and b/project01/01.Python环境部署/image-20250908103300961.png differ diff --git a/project01/01.Python环境部署/image-20250908103521450.png b/project01/01.Python环境部署/image-20250908103521450.png new file mode 100644 index 0000000..1aca00e Binary files /dev/null and b/project01/01.Python环境部署/image-20250908103521450.png differ diff --git a/project01/01.Python环境部署/image-20250908103720353.png b/project01/01.Python环境部署/image-20250908103720353.png new file mode 100644 index 0000000..47e4cd3 Binary files /dev/null and b/project01/01.Python环境部署/image-20250908103720353.png differ diff --git a/project01/01.Python环境部署/image-20250908103851450.png b/project01/01.Python环境部署/image-20250908103851450.png new file mode 100644 index 0000000..e04ee1a Binary files /dev/null and b/project01/01.Python环境部署/image-20250908103851450.png differ diff --git a/project01/01.Python环境部署/image-20250908103938229.png b/project01/01.Python环境部署/image-20250908103938229.png new file mode 100644 index 0000000..2f96475 Binary files /dev/null and b/project01/01.Python环境部署/image-20250908103938229.png differ diff --git a/project01/01.Python环境部署/image-20250908104000089.png b/project01/01.Python环境部署/image-20250908104000089.png new file mode 100644 index 0000000..3ceaee5 Binary files /dev/null and b/project01/01.Python环境部署/image-20250908104000089.png differ diff --git a/project01/01.Python环境部署/image-20250908105245692.png b/project01/01.Python环境部署/image-20250908105245692.png new file mode 100644 index 0000000..d0ceedc Binary files /dev/null and b/project01/01.Python环境部署/image-20250908105245692.png differ diff --git a/project01/01.Python环境部署/image-20250908105511298.png b/project01/01.Python环境部署/image-20250908105511298.png new file mode 100644 index 0000000..c06ae32 Binary files /dev/null and b/project01/01.Python环境部署/image-20250908105511298.png differ diff --git a/project01/01.Python环境部署/image-20250908105532634.png b/project01/01.Python环境部署/image-20250908105532634.png new file mode 100644 index 0000000..ea263ac Binary files /dev/null and b/project01/01.Python环境部署/image-20250908105532634.png differ diff --git a/project01/01.Python环境部署/image-20250908110107975.png b/project01/01.Python环境部署/image-20250908110107975.png new file mode 100644 index 0000000..e6fbc0e Binary files /dev/null and b/project01/01.Python环境部署/image-20250908110107975.png differ diff --git a/project01/01.Python环境部署/image-20250908110152211.png b/project01/01.Python环境部署/image-20250908110152211.png new file mode 100644 index 0000000..d717498 Binary files /dev/null and b/project01/01.Python环境部署/image-20250908110152211.png differ diff --git a/project01/01.Python环境部署/image-20250908110248322.png b/project01/01.Python环境部署/image-20250908110248322.png new file mode 100644 index 0000000..0dc0f6e Binary files /dev/null and b/project01/01.Python环境部署/image-20250908110248322.png differ diff --git a/project01/01.Python环境部署/image-20250908110328448.png b/project01/01.Python环境部署/image-20250908110328448.png new file mode 100644 index 0000000..649461c Binary files /dev/null and b/project01/01.Python环境部署/image-20250908110328448.png differ diff --git a/project01/01.Python环境部署/image-20250908110405537.png b/project01/01.Python环境部署/image-20250908110405537.png new file mode 100644 index 0000000..1522504 Binary files /dev/null and b/project01/01.Python环境部署/image-20250908110405537.png differ diff --git a/project01/01.Python环境部署/image-20250908110806880.png b/project01/01.Python环境部署/image-20250908110806880.png new file mode 100644 index 0000000..49856c7 Binary files /dev/null and b/project01/01.Python环境部署/image-20250908110806880.png differ diff --git a/project01/01.Python环境部署/image-20250908110841673.png b/project01/01.Python环境部署/image-20250908110841673.png new file mode 100644 index 0000000..cc6e337 Binary files /dev/null and b/project01/01.Python环境部署/image-20250908110841673.png differ diff --git a/project01/01.Python环境部署/image-20250908110950343.png b/project01/01.Python环境部署/image-20250908110950343.png new file mode 100644 index 0000000..a7f0600 Binary files /dev/null and b/project01/01.Python环境部署/image-20250908110950343.png differ diff --git a/project01/01.Python环境部署/image-20250908111030150.png b/project01/01.Python环境部署/image-20250908111030150.png new file mode 100644 index 0000000..f351f8c Binary files /dev/null and b/project01/01.Python环境部署/image-20250908111030150.png differ diff --git a/project01/01.Python环境部署/image-20250908111150143.png b/project01/01.Python环境部署/image-20250908111150143.png new file mode 100644 index 0000000..8e664a7 Binary files /dev/null and b/project01/01.Python环境部署/image-20250908111150143.png differ diff --git a/project01/01.Python环境部署/image-20250908111555981.png b/project01/01.Python环境部署/image-20250908111555981.png new file mode 100644 index 0000000..6ea8dc1 Binary files /dev/null and b/project01/01.Python环境部署/image-20250908111555981.png differ diff --git a/project01/01.Python环境部署/image-20250908111655330.png b/project01/01.Python环境部署/image-20250908111655330.png new file mode 100644 index 0000000..7965bf5 Binary files /dev/null and b/project01/01.Python环境部署/image-20250908111655330.png differ diff --git a/project01/01.Python环境部署/image-20250908111746430.png b/project01/01.Python环境部署/image-20250908111746430.png new file mode 100644 index 0000000..01228b4 Binary files /dev/null and b/project01/01.Python环境部署/image-20250908111746430.png differ diff --git a/project01/01.Python环境部署/image-20250908111815827.png b/project01/01.Python环境部署/image-20250908111815827.png new file mode 100644 index 0000000..3a43bb8 Binary files /dev/null and b/project01/01.Python环境部署/image-20250908111815827.png differ diff --git a/project01/01.Python环境部署/image-20250908111935788.png b/project01/01.Python环境部署/image-20250908111935788.png new file mode 100644 index 0000000..f9705da Binary files /dev/null and b/project01/01.Python环境部署/image-20250908111935788.png differ