没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论























Python学习笔记
E-mail : pidaqing@0335.net
c
°2003-2003。皮大庆。保留所有权利。
你可以拷贝或打印这本书,但是禁止将其内容用于商业用途。
对于书中的内容和程序,作者不提供任何显示或隐含的担保。

前前前言言言
Python是一种新兴的计算机程序语言,是自由软件运动的丰硕成果。
Python是一种免费的、解释型的、可移植的、开放源代码的脚本编程
语言。它提供了大量的模块,不仅加快了程序开发速度和代码的清晰程
度,而且使程序员专注于要解决的问题,不会陷入繁琐的技术细节。它可
以用来开发各种应用程序,从简单的脚本任务到复杂的、面向对象的应用
程序。
Python是一种脚本语言,它的语法表达优美易读。它具有很多优秀的
脚本语言的特点:
• 解释的;
• 面向对象的;
• 内建的高级数据结构;
• 支持模块和包;
• 支持多种平台;
• 可扩展。
它非常适合于教学。在学习Python的过程中,它可以使学生专注计算
机程序语言的基本概念,着中理解现代程序语言的精髓,而不必理会那
些细枝末节、令人头痛技术细节,这些细节问题不但难于讲解,也很难理
解,而且还会使学生产生厌烦情绪,无助于计算机程序语言的学习。
我在学习《How to Think Like a Computer Scientist》的过程中,发现
这本书很适合初学编程语言者,而且深深被Python迷住了,因此就整理出
这本笔记,供大家参考。希望诸位多提意见,逐渐完善它,最终使它成为
“指南”之类参考书,不再是笔记。
I love Python!
i

目目目录录录
前前前言言言 i
第第第一一一章章章 程程程序序序 1
1.1 程序 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 什么是调试 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 调试 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.4 程序语言和自然语言 . . . . . . . . . . . . . . . . . . . . . . . 4
1.5 第一个程序 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
第第第二二二章章章 变变变量量量,,,表表表达达达式式式和和和语语语句句句 6
2.1 变量和类型 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.2 变量名和关键字 . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.3 语句 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.4 表达式 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.5 运算符和操作数 . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.6 运算的顺序 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.7 字符串操作 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.8 组合 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.9 注释 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
第第第三三三章章章 函函函数数数 16
3.1 函数 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.2 函数定义 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.3 函数的行参和实参 . . . . . . . . . . . . . . . . . . . . . . . . 17
3.4 变量的范围 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.5 函数的返回值 . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.6 类型转换 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.7 数学函数模块 . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.8 lambda函数 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
ii

我我我爱爱爱Python!!!
第第第四四四章章章 条条条件件件表表表达达达式式式 24
4.1 布尔表达式 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.2 逻辑操作符 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.3 条件语句 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
4.4 while语句 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
4.5 条件嵌套 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
4.6 return语句 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.7 键盘输入 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
第第第五五五章章章 字字字符符符串串串 32
5.1 组合数据类型 . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
5.2 用for语句遍历字符串 . . . . . . . . . . . . . . . . . . . . . . . 33
5.3 字符串片断 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
5.4 字符串模块 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
第第第六六六章章章 列列列表表表 37
6.1 列表值 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
6.2 读写元素 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
6.3 列表的一些方法 . . . . . . . . . . . . . . . . . . . . . . . . . . 39
6.4 列表长度 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
6.5 列表和for循环 . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
6.6 列表操作符 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
6.7 列表片断 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
6.8 列表元素是可变的 . . . . . . . . . . . . . . . . . . . . . . . . 43
6.9 元素的删除 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
6.10 变量和值 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
6.11 别名 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
6.12 克隆列表 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
6.13 列表参数 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
6.14 列表嵌套 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
6.15 矩阵 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
6.16 字符串和列表 . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
6.17 列表映射 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
第第第七七七章章章 序序序列列列 51
7.1 序列 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
7.2 序列赋值 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
7.3 序列作为返回值 . . . . . . . . . . . . . . . . . . . . . . . . . . 53
7.4 随机函数 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
7.5 随机数列表 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
7.6 计数 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
iii

我我我爱爱爱Python!!!
7.7 分割范围 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
第第第八八八章章章 字字字典典典 58
8.1 字典操作 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
8.2 别名和拷贝 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
8.3 稀疏矩阵 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
8.4 暗示 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
8.5 计算字符串 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
第第第九九九章章章 文文文件件件 64
9.1 文件的打开和关闭 . . . . . . . . . . . . . . . . . . . . . . . . 64
9.2 文本文件 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
9.3 写入变量 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
第第第十十十章章章 异异异常常常 71
10.1 错误信息 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
10.2 自定义异常信息 . . . . . . . . . . . . . . . . . . . . . . . . . . 72
10.3 一个复杂的例子 . . . . . . . . . . . . . . . . . . . . . . . . . . 72
第第第十十十一一一章章章 类类类和和和对对对象象象 74
11.1 用户定义数据类型 . . . . . . . . . . . . . . . . . . . . . . . . 74
11.2 属性 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
11.3 同一性 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
11.4 长方形类 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
11.5 拷贝 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
第第第十十十二二二章章章 类类类与与与方方方法法法 81
12.1 面向对象的技术 . . . . . . . . . . . . . . . . . . . . . . . . . . 81
12.2 可选择的参数 . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
12.3 构造函数 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
第第第十十十三三三章章章 操操操作作作符符符重重重定定定义义义 86
13.1 加减法重定义 . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
13.2 乘法重定义 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
第第第十十十四四四章章章 继继继承承承 90
14.1 继承 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
14.2 继承的定义 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
14.3 定义一个父类 . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
14.4 继承Person的子类 . . . . . . . . . . . . . . . . . . . . . . . . 91
14.5 私有方法 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
iv
剩余97页未读,继续阅读
资源评论


xuwedo2003
- 粉丝: 31
- 资源: 195
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- CVPR2023:新型注意力机制助力YOLOv5至v8实现创新暴涨点体验,CVPR2023创新:全新注意力机制助力YOLOv5、v7、v8实现暴力涨点,cvpr2023全新注意力机制加入到YOLOv5
- 基于STM32G474的微型逆变器设计方案:源代码、原理图及PCB布局解析,基于STM32G474的微型逆变器设计方案,附源代码原理图与PCB设计参考图,400w微型逆变器, 基于stm32g474实
- Ollama 本地GUI客户端:为DeepSeek用户量身定制的智能模型管理与交互工具
- Deep Seek R1 Windows AI 助手 APP
- 基于栅格地图的人工势场法与A*、RRT融合的动态路径规划算法:自由设定起点目标点及地图,基于珊格地图的动态路径规划算法:人工势场法与A*、RRT融合实现,基于珊格地图的人工势场法 动态路径规划 路径规
- 基于JavaWeb(JSP)+MySQL图书销售管理系统(网上书店)项目源码
- 基于Comsol的变压器铁心磁致伸缩振动仿真技术研究,Comsol多物理场仿真技术下的变压器铁心磁致伸缩振动研究,Comsol 变压器铁心磁致伸缩振动仿真 ,Comsol; 变压器铁心; 磁致伸缩振
- VSCode安装包v-1.97.2
- 爱奇艺用户画像以及用户行为数据.zip
- 西门子S7-1500 PLC程序案例:制药厂洁净空调精准控温控湿解决方案,采用SCL编程,附详细注释,博图V16版本 ,西门子S7-1500 PLC程序案例:制药厂洁净空调精准控温与湿度调节方案,采用
- 数理逻辑与图论-考证必备题目+题解.zip
- 此资源为暂存文件用于学习使用
- DOTween Pro1.0.244
- 管家婆普及版TOP12.9.zip
- 管家婆普及版TOP12.51.zip
- 管家婆普及版TOP12.71.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
