# Python入门
## 编程基本概念
### Python程序的构成
1. 连接符 \ 一行代码过长,变成多行时使用
2. 强制使用缩进,四个空格表示一个缩进
### 对象的基本组成和内存示意图
![image-20231110201745676](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311102017825.png)![image-20231110201950773](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311102019862.png)![image-20231110202237621](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311102022690.png)
### 引用的本质-栈内存和堆内存-内存示意图
![image-20231110202507724](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311102025811.png)![image-20231110202618382](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311102026455.png)
**==Python是动态类型语言==:变量不需要显式声明类型。根据变量引用的对象,Python解释器自动确定数据类型**
### 标识符-帮助系统简单使用-命名规则
![image-20231110203017623](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311102030659.png)![image-20231110203126470](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311102031531.png)![image-20231110203446167](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311102034233.png)
### 变量的声明-初始化-垃圾回收机制
![image-20231110204145297](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311102041345.png)
### 常量-链式赋值-系列解包赋值
![image-20231110204256608](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311102042669.png)
![image-20231110204725378](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311102047432.png)
![image-20231110205028675](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311102050729.png)
**使用系列解包复制可以轻松实现变量值交换**
### 内置数据类型-基本算术运算符
![image-20231110210320597](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311102103657.png)![image-20231110210508378](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311102105449.png)
### 整数-不同进制-其他类型转成整数
==**Python的整数可以无限大,任意大**==
![image-20231110210750024](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311102107064.png)![image-20231110210944115](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311102109168.png)![image-20231110211017712](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311102110784.png)
### 浮点数-自动转换强制转换-增强赋值运算符
![image-20231110211408060](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311102114124.png)
==**round(value))**可以返回**四舍五入**的值==。但**不会改变原有值**,而是产生新的值
![image-20231110211636512](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311102116576.png)
### 时间的表示-unix时间点-毫秒微妙-time模块
![image-20231110212157494](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311102121561.png)![image-20231110212401113](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311102124175.png)
### 多点坐标-绘制折线图-计算两点距离
### 布尔值本质-逻辑运算符-位运算符-比较运算符-短路问题![image-20231110213752664](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311102153527.png)![image-20231110213917617](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311102153409.png)
![image-20231110214203652](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311102154007.png)
![image-20231110214628683](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311102154153.png)
**关系运算符可以连用 如: `2<a<10`**
![image-20231110214823887](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311102222183.png)
![image-20231110220532227](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311102222184.png)
**字符串拼接 `"3"+"4"` 结果 `"34"`**
**列表,元组等合并 `[1,2,3]+[4,5,6]` 结果 `[1,2,3,4,5,6]`**
**字符串复制 `"abc"* 3` 结果 `"abcabcabc"`**
**列表,元组等复制 `[1,2,3] * 3` 结果 `[1,2,3,1,2,3,1,2,3]`**
![image-20231110220550583](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311102222185.png)
**与C和AVA不一样,Python不支持自增(++)和自减(--)**
### 同一运算符-身份运算符-优先级问题
![image-20231110220915376](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311102222186.png)
![image-20231110221003673](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311102222187.png)
![image-20231110221419620](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311102222188.png)
![image-20231110221607995](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311102222189.png)
![image-20231110221752500](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311102222190.png)
![image-20231110221929772](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311102222191.png)
![image-20231110222043769](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311102222192.png)
### 类型转换总结
![image-20231111205424806](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311112327707.png)
## 序列
![image-20231112203832984](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311141608618.png)
![image-20231112204030526](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311141608619.png)
![image-20231112204122105](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311141608620.png)
==序列中存储的是整数对象的地址,而不是整数对象的值==
![image-20231112204257128](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311141608621.png)
### 字符串
#### unicode字符集-三种创建字符串的方式-len()
![image-20231111165047001](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311112327671.png)
![image-20231111165027593](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311112327672.png)
![image-20231111165127201](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311112327673.png)
![image-20231111165242915](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311112327675.png)
![image-20231111165439485](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311112327676.png)
![image-20231111165530787](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311112327677.png)
#### 转义字符-字符串拼接-字符串复制-input()获取键盘输入
![image-20231111165827750](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311112327678.png)
![image-20231111165929426](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311112327679.png)
![image-20231111170036120](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311112327680.png)
![image-20231111170117738](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311112327681.png)
![image-20231111170146635](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311112327682.png)
#### str()-字符提取-replace()替换-内存分析
![image-20231111170618209](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311112327683.png)
==**字符串是不可变的**==
![image-20231111170815318](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311112327684.png)
![image-20231111170925169](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311112327685.png)
#### 切片slice操作-逆序
![image-20231111171200785](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311112327686.png)
![image-20231111171239402](https://gitee.com/huaiyuechusan/picture/raw/master/Typora/202311112327687.png)
![image-20231111172118356](https:/
没有合适的资源?快使用搜索试试~ 我知道了~
Python入门代码练习 .zip
共13个文件
xml:6个
py:3个
txt:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 182 浏览量
2024-04-19
21:25:40
上传
评论
收藏 30KB ZIP 举报
温馨提示
python入门 单元测试和测试用例 Python标准库中的模块unittest提供了代码测试工具。 单元测试用于核实函数的某个防霾呢没有问题; 测试用例是一组单元测试,这些单元测试仪器一起核实函数在各种情形下的行为都符合要求。良好的测试用例考虑到了函数可能收到的各种收入,包含所有针对这些情形的测试。 全覆盖式测试用例包含一整套单元测试,涵盖了各种可能的函数使用方式。 对于大型项目,要实现全覆盖可能很难。通常,最初只要对针对代码的重要行为编写测试即可,等项目给广泛使用时再考虑全覆盖。 可通过的测试 创建测试用例的语法需要一段时间才能习惯,但测试用例创建后,再添加针对函数的单元测试就很简单了。要为函数编写测试用例,可先导入模块unittest以及要测试的函数,在创建一个继承unittest.TestCase的类,并编写一系列方法对函数行为的不同方面进行测试。 下面test_name_function.py一个只包含一个方法的测试用例,它检查函数get_formatted_name()在给定名和姓时能否正确的工作。
资源推荐
资源详情
资源评论
收起资源包目录
Python入门代码练习。.zip (13个子文件)
新建文本文档.txt 1KB
getting-started-with-python-master
面向对象
practice.py 7KB
.idea
Python基础.iml 317B
vcs.xml 180B
misc.xml 185B
inspectionProfiles
Project_Default.xml 1KB
profiles_settings.xml 174B
modules.xml 276B
deployment.xml 631B
.gitignore 176B
函数和内存分析
practice.py 1KB
控制语句
practice.py 6KB
README.md 73KB
共 13 条
- 1
资源评论
野生的狒狒
- 粉丝: 2352
- 资源: 2099
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- IMG_0694.GIF
- 基于图像的三维模型重建C++源代码+文档说明(高分课程设计)
- 基于聚焦法的工件立体测量方案,根据数据进行三维重建 使用HALCON处理图像,MATLAB拟合数据+源代码+数据集+效果图
- 锄战三国村 修改:货币使用不减 v1.10(2) 原创 (中文).apk
- 基于python实现的单目双目视觉三维重建+源代码+图像图片(高分课程设计)
- 基于C+++OPENCV的全景图像拼接源码(课程设计)
- 基于Python+OpenCV对多张图片进行全景图像拼接,消除鬼影,消除裂缝+源代码+文档说明+界面截图(高分课程设计)
- 基于C++实现的全景图像拼接源码(课程设计)
- 基于SIFT特征点提取和RASIC算法实现全景图像拼接python源码+文档说明+界面截图+详细注释(95分以上课程大作业)
- 基于matlab实现眼部判别的疲劳检测系统+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功