Python: Complete Case-Based Learning and Practice cover

Python: Complete Case-Based Learning and Practice

Rating 3.0
Word count
216K words
Chapters
402
ISBN
9787121373008

Tags

Summary

This book is an introductory text for all Python learners, including graduate students, undergraduate and vocational students, and middle school students. Following the principles of "sufficient, applicable, and easy to learn," it organizes and designs its framework and content in four parts: Part One—Setting Up the Environment, mainly covering the learning environment and platform installation, use of IDLE and PyCharm, and common internal and external modules and their installation. Part Two—Lifting the Lid, focusing on Python's main syntax: data types, variables and constants, statements, input and output, functions and modularization, files and objects, classes, and exceptions. Part Three—Hands-On Practice, presenting four complete application cases covering desktop mini-games, data mining and analysis, image recognition and machine learning, and intelligent detection and control. Part Four—Moving Forward, focusing on packaging script files, writing Pythonic code, and the breadth and depth of Python. The book has two distinctive features in content organization and framework design: all-case-based and learner-centered. Each chapter's content system is organized from the learner's perspective, almost every knowledge point is accompanied by examples, and four complete comprehensive engineering cases are provided, all of which greatly facilitate learning and imitation. The book is suitable for professional and non-professional readers at all levels who are interested in Python.

Editor's review

As a technical editor, when I first encountered Python全案例学习与实践, I was drawn in by its subtitle, "a Python book you can truly teach yourself from." After reading through it in depth, I believe it genuinely offers programming beginners a thoughtfully crafted learning path.

The book's core value lies in its "all-case-driven" approach. Professor Shen Hongwei abandons the dry syntax-to-syntax listing of traditional textbooks in favor of more than 200 practical cases that progress from simple to advanced. These cases are not a mere pile of code snippets but carefully designed, interconnected "building blocks." Readers grasp core concepts such as variables, loops, functions, and object orientation almost without noticing as they assemble the blocks. This "learning by doing" approach greatly reduces beginners' cognitive load and turns abstract programming thinking into tangible practical results.

Another hallmark of the book is its systematic content and engineering-practice orientation. It covers not only essential knowledge such as Python basic syntax, data structures, and file operations but also extends to popular application areas such as web scraping, data analysis, and graphical interfaces. Particularly noteworthy is the dedicated "Engineering Practice" section, which guides learners to modularize scattered knowledge into projects and cultivates the comprehensive ability to solve real problems. This progression from "knowledge points" to "knowledge surfaces" to a "knowledge body" reflects the author's deep understanding of learning patterns as a front-line educator.

Professor Shen Hongwei's teaching background gives the book a distinctive "tutorial feel." The language is plain and friendly, like an experienced mentor guiding you step by step at your side, and it anticipates and answers beginners' common mistakes and mental stumbling blocks with precision. Although the book may not go as deep as purely advanced monographs, it strikes an excellent balance between "introduction" and "getting hands-on," building learners a solid and extensible cognitive framework. For readers eager to truly master Python through practice and to establish correct programming thinking, this book is a reliable map.

Who it's for

A good fit for

  • Absolute beginners in programming who want a painless entry path
  • Non-computer professionals who need to apply Python to scenarios such as data analysis and office automation
  • Students in computer-related majors at colleges and universities seeking a practical guide complementary to their courses
  • Developers with some background in other languages who want to switch quickly to Python and learn about its typical applications

Not a good fit for

  • Senior programmers seeking in-depth explanations of Python's underlying mechanisms, advanced features, or source code analysis
  • Readers who want a concise tool manual for quickly looking up APIs or syntax details

Reading tips

  1. It is recommended to proceed strictly in chapter order, because the cases build on and relate to one another
  2. Hands-on practice is key; be sure to type out and run every case code in your own environment
  3. After each chapter, try making small modifications to or combinations of the cases to test your understanding

About the publisher

Publishing House of Electronics Industry China · Founded in 1982

The Publishing House of Electronics Industry is a comprehensive publisher distinguished by its focus on electronic information and related fields. Judging from the more than 3,000 titles in its catalogue, its publishing covers programming and design, artificial intelligence, computer science, finance and economics, photography, and social sciences, attending both to cutting-edge technology and to general readers. Representative titles include Factor Investing: Methods and Practice, x86 Assembly Language: From Real Mode to Protected Mode, The RISC-V Reader, Artificial Intelligence: Speech Recognition, Understanding and Practice, Phased Array Radar Technology, Radar Target Characteristics, and 100 Go Mistakes and How to Avoid Them, most of which centre on technical methods and engineering practice. Its authors include Shi Chuan, Li Zhong, Wang Xiaobo, David Patterson, Andrew Waterman, and Yu Zihao, among others from China and abroad. Owing to limited public information, no further publishing features are elaborated here.

Contents

  1. 版权信息
  2. 内容简介
  3. 前言
  4. 第1篇 营造环境
  5. 第1章 Python及其安装
  6. 1.1 为什么要学习Python
  7. 1.1.1 Python的广泛性
  8. 1.1.2 Python的新颖性
  9. 1.1.3 Python的生态性
  10. 1.1.4 Python的应用领域举例
  11. 1.1.5 Python的局限性
  12. 1.2 学习Python的必备“神器”
  13. 1.2.1 Python概况
  14. 1.2.2 常用的Python集成开发环境
  15. 1.3 安装和设置Python
  16. 1.3.1 获取Python
  17. 1.3.2 安装Python
  18. 1.3.3 设置Python
  19. 思考与实践
  20. 第2章 IDLE的使用
  21. 2.1 IDLE的安装与设置
  22. 2.1.1 IDLE的安装
  23. 2.1.2 IDLE的启动
  24. 2.1.3 IDLE的个性化设置
  25. 2.2 Edit编辑模式与Shell命令行模式的切换
  26. 2.2.1 Edit编辑模式与Shell命令行模式的切换方式
  27. 2.2.2 IDLE的文本编辑功能
  28. 2.3 在IDLE中运行程序
  29. 2.3.1 在Edit模式下运行程序
  30. 2.3.2 在Shell模式下运行程序
  31. 2.4 IDLE的程序调试功能
  32. 2.4.1 两种调试方法
  33. 2.4.2 在Shell模式下的程序调试
  34. 2.4.3 在Edit模式下的程序调试
  35. 2.4.4 断点调试
  36. 2.5 在Shell模式下如何清屏
  37. 思考与实践
  38. 第3章 安装PyCharm
  39. 3.1 PyCharm及其安装
  40. 3.1.1 PyCharm的3种版本形式
  41. 3.1.2 获取PyCharm
  42. 3.1.3 安装PyCharm
  43. 3.2 PyCharm的个性化设置
  44. 3.2.1 设置入口
  45. 3.2.2 外观设置
  46. 3.2.3 Editor与自动代码补齐设置
  47. 3.2.4 解释器设置
  48. 3.2.5 运行键设置
  49. 思考与实践
  50. 第4章 Python的标准资源
  51. 4.1 Python内置的标准模块
  52. 4.1.1 通过help()命令查看内置模块
  53. 4.1.2 通过IDLE的【Help】菜单查看内置模块
  54. 4.1.3 常用内置模块及其功能介绍
  55. 4.1.4 内置模块的主要函数(方法)简介
  56. 4.2 内置模块的应用举例
  57. 4.2.1 与路径相关的应用举例
  58. 4.2.2 与时间相关的应用举例
  59. 4.3 Python的内置函数
  60. 4.3.1 如何查看Python有哪些内置函数
  61. 4.3.2 内置函数及其功能
  62. 4.3.3 内置函数的应用举例
  63. 思考与实践
  64. 第5章 Python的外部资源
  65. 5.1 为什么要安装外部模块
  66. 5.2 如何安装外部模块
  67. 5.2.1 升级安装工具
  68. 5.2.2 使用pip安装外部模块
  69. 5.2.3 使用easy_install安装外部模块
  70. 5.3 将安装后的外部模块导入PyCharm中
  71. 5.4 通过PyCharm安装外部模块
  72. 5.4.1 通过Project Interpreter方式安装外部模块
  73. 5.4.2 通过Plugins方式安装外部模块
  74. 5.5 常用的外部模块及其应用
  75. 5.5.1 常用的外部模块
  76. 5.5.2 外部模块的应用举例
  77. 思考与实践
  78. 第2篇 掀起盖头
  79. 第6章 我的Python处女作
  80. 6.1 新建工程
  81. 6.1.1 新建工程文件
  82. 6.1.2 新建Python文件
  83. 6.1.3 配置工程并运行
  84. 6.2 关于工程及其要注意的3个事项
  85. 6.2.1 关于首次运行程序的注意事项
  86. 6.2.2 关于工程的必要设置
  87. 6.2.3 关于运行与调试功能的设置问题
  88. 6.2.4 关于3种运行方式
  89. 思考与实践
  90. 第7章 Python的数据类型
  91. 7.1 Python程序的基本组成
  92. 7.1.1 一个温度转换的例子
  93. 7.1.2 程序的注释
  94. 7.1.3 语句
  95. 7.1.4 常量
  96. 7.1.5 变量
  97. 7.1.6 标识符
  98. 7.1.7 函数
  99. 7.2 Python的数据类型及其有关特性
  100. 7.2.1 Python的数据类型分类
  101. 7.2.2 Python变量的基本特性
  102. 7.3 Python中的常量
  103. 7.3.1 数字
  104. 7.3.2 字符串
  105. 7.3.3 布尔值
  106. 7.3.4 空值
  107. 7.4 Python中的基本类型变量
  108. 7.4.1 变量的使用
  109. 7.4.2 基本变量的赋值
  110. 7.4.3 变量的地址
  111. 7.5 Python中的构造类型变量
  112. 7.5.1 字符串
  113. 7.5.2 列表
  114. 7.5.3 元组
  115. 7.5.4 集合
  116. 7.5.5 字典
  117. 7.6 归纳与总结
  118. 7.6.1 各种类型的相互转换
  119. 7.6.2 字符串、列表、元组、字典和集合的异同点
  120. 思考与实践
  121. 第8章 Python的数据运算
  122. 8.1 运算符的分类
  123. 8.2 运算符的功能与特点
  124. 8.2.1 算术运算符
  125. 8.2.2 比较运算符
  126. 8.2.3 赋值运算符
  127. 8.2.4 逻辑运算符
  128. 8.2.5 成员运算符
  129. 8.2.6 身份运算符
  130. 8.2.7 位运算符
  131. 8.3 运算符的优先级
  132. 8.3.1 优先级与结合性
  133. 8.3.2 优先级的使用举例
  134. 思考与实践
  135. 第9章 键盘输入与屏幕输出
  136. 9.1 键盘输入与input()函数
  137. 9.1.1 input()函数的功能
  138. 9.1.2 数据类型之间的转换
  139. 9.2 屏幕输出与print()函数
  140. 9.2.1 print()函数的功能
  141. 9.2.2 print()函数的3种使用形式
  142. 9.3 练一练:通用倒计时器
  143. 9.3.1 程序设计要求与具体程序
  144. 9.3.2 程序的两种运行方式
  145. 9.4 归纳与总结
  146. 思考与实践
  147. 第10章 学会选择靠if语句
  148. 10.1 选择问题与if语句
  149. 10.2 if语句的3种语法形式
  150. 10.2.1 if语句的第一种语法形式
  151. 10.2.2 if语句的第二种语法形式
  152. 10.2.3 if语句的第三种语法形式
  153. 10.3 多重if语句与if语句的嵌套
  154. 10.4 关于if语句的重要小结
  155. 10.5 练一练——正整数分离
  156. 思考与实践
  157. 第11章 重复操作与循环语句
  158. 11.1 循环及其应用
  159. 11.2 while和for语句
  160. 11.2.1 while语句
  161. 11.2.2 for语句
  162. 11.3 break和continue语句
  163. 11.4 练一练——摄氏与华氏温度转换
  164. 11.4.1 程序设计要求与具体程序
  165. 11.4.2 程序的详细分析
  166. 11.5 归纳与总结
  167. 11.5.1 循环语句for与while的else扩展
  168. 11.5.2 break与continue语句的区别
  169. 思考与实践
  170. 第12章 函数让程序优雅
  171. 12.1 什么是函数
  172. 12.1.1 函数的概念
  173. 12.1.2 为什么要使用函数
  174. 12.2 函数的定义与调用
  175. 12.2.1 如何定义一个函数
  176. 12.2.2 如何调用函数
  177. 12.3 函数的参数传递与不定长参数
  178. 12.3.1 不可变类型参数的传递与可变类型参数的传递
  179. 12.3.2 必须参数、默认参数与关键词参数
  180. 12.3.3 不定长参数
  181. 12.4 匿名函数
  182. 12.5 变量的作用范围
  183. 12.6 练一练——“剪刀、石头、布”游戏
  184. 12.6.1 程序设计要求与算法设计
  185. 12.6.2 完整程序与运行结果
  186. 12.7 归纳与总结
  187. 12.7.1 函数的意义
  188. 12.7.2 return语句
  189. 12.7.3 关于默认参数
  190. 12.7.4 if__name__=='__main__'的作用
  191. 思考与实践
  192. 第13章 “分而治之”与程序的模块化
  193. 13.1 模块化及其意义
  194. 13.1.1 为什么要模块化
  195. 13.1.2 什么是模块
  196. 13.2 如何定义和使用模块
  197. 13.2.1 中模块——文件模块的定义与应用
  198. 13.2.2 模块是如何被找到并引用的——模块搜索路径
  199. 13.3 大模块——包的定义与应用
  200. 13.3.1 什么是“包”
  201. 13.3.2 如何定义包
  202. 13.3.3 包的使用
  203. 13.4 归纳与总结
  204. 思考与实践
  205. 第14章 文件与数据格式化
  206. 14.1 文件及其操作
  207. 14.1.1 文件概述
  208. 14.1.2 打开文件——open()函数
  209. 14.1.3 打开文件举例
  210. 14.1.4 读文件
  211. 14.1.5 写文件
  212. 14.1.6 文件指针及其移动
  213. 14.1.7 关闭文件
  214. 14.2 文件的应用举例——词频统计
  215. 14.2.1 英文文献的词频统计
  216. 14.2.2 jieba模块与中文文献的词频统计
  217. 14.3 CSV格式文件与JSON格式文件的操作
  218. 14.3.1 CSV格式文件及其操作
  219. 14.3.2 JSON格式文件及其操作
  220. 14.4 归纳与总结
  221. 14.4.1 关于文件的几点注意事项
  222. 14.4.2 文件的迭代
  223. 思考与实践
  224. 第15章 面向对象与类——让程序更人性化
  225. 15.1 面向对象与类
  226. 15.1.1 面向过程的程序设计
  227. 15.1.2 面向对象的程序设计
  228. 15.1.3 类
  229. 15.2 类的定义
  230. 15.2.1 类的定义与__init__()方法
  231. 15.2.2 实例方法、类方法和静态方法
  232. 15.2.3 实例变量与类变量
  233. 15.2.4 私有属性和私有方法
  234. 15.3 类的使用
  235. 15.3.1 不带默认属性的类及其使用
  236. 15.3.2 带默认属性的类及其使用
  237. 15.3.3 类的组合使用
  238. 15.4 类的封装性
  239. 15.4.1 什么是封装
  240. 15.4.2 如何封装
  241. 15.5 类的继承性
  242. 15.5.1 什么是继承
  243. 15.5.2 类的单继承
  244. 15.5.3 构造函数的继承
  245. 15.5.4 类的多继承
  246. 15.5.5 类的多级继承
  247. 15.5.6 类的混合继承
  248. 15.6 类的多态性
  249. 15.6.1 什么是多态性
  250. 15.6.2 多态性举例
  251. 15.7 从模块中导入类
  252. 15.8 归纳与总结
  253. 15.8.1 类方法的属性化
  254. 15.8.2 关于内置变量__mro__
  255. 15.8.3 关于内置函数issubclass()与isinstance()
  256. 15.8.4 关于内置函数dir()
  257. 思考与实践
  258. 第16章 异常处理让程序健壮
  259. 16.1 错误与异常
  260. 16.1.1 错误(Error)
  261. 16.1.2 异常(Exception)
  262. 16.1.3 常见的标准异常
  263. 16.1.4 自定义异常
  264. 16.1.5 为什么要进行异常处理
  265. 16.2 异常处理的一般方法——try语句
  266. 16.2.1 try语句的一般语法
  267. 16.2.2 try语句的执行过程分析
  268. 16.3 异常处理的特殊方法——with语句
  269. 16.3.1 上下文管理
  270. 16.3.2 为什么要使用with语句
  271. 16.3.3 with语句的一般形式
  272. 16.3.4 with语句的工作机制
  273. 16.3.5 自定义上下文管理器
  274. 16.3.6 以Socket通信举例说明上下文管理器的定义
  275. 16.4 归纳与总结
  276. 16.4.1 关于try语句
  277. 16.4.2 关于异常的其他问题
  278. 16.4.3 关于Socket通信的再说明
  279. 思考与实践
  280. 第3篇 实战演习
  281. 第17章 桌面小游戏——剪刀、石头、布
  282. 17.1 图形化人机界面GUI及其应用
  283. 17.2 基于GUI的“剪刀、石头、布”游戏的算法与类的设计
  284. 17.2.1 算法设计
  285. 17.2.2 类的设计
  286. 17.2.3 计算机出拳的实现
  287. 17.2.4 最高得分的保存与读取
  288. 17.2.5 图形化界面
  289. 17.2.6 按键和鼠标的捕捉与处理
  290. 17.3 编辑程序
  291. 17.3.1 新建PyCharm工程
  292. 17.3.2 完整的源程序
  293. 17.3.3 程序运行效果
  294. 17.4 归纳与总结
  295. 17.4 .1 设置解释器时出现“Cannot Save Settings”错误及其解决办法
  296. 17.4.2 将代码生成可执行文件
  297. 思考与实践
  298. 第18章 数据挖掘与分析——Bilibili视频爬虫
  299. 18.1 数据挖掘与网络爬虫
  300. 18.1.1 数据挖掘
  301. 18.1.2 网络爬虫
  302. 18.1.3 网络爬虫的工作原理
  303. 18.1.4 实现网络爬虫的关键技术
  304. 18.1.5 爬虫的基本框架
  305. 18.1.6 反爬虫与Robots协议
  306. 18.2 Python网络爬虫的开发平台与环境
  307. 18.3 爬虫的案例—B站网络爬虫
  308. 18.3.1 功能与设计要求
  309. 18.3.2 目标URL和应用接口的获取
  310. 18.3.3 举例:如何快速找到B站全站视频信息的公共接口(API)
  311. 18.3.4 算法与流程图
  312. 18.3.5 多进程与多线程的选择
  313. 18.3.6 完整的程序代码
  314. 18.4 归纳与总结
  315. 18.4.1 关于requests中get()方法的几点注意事项
  316. 18.4.2 爬虫尺寸
  317. 18.4.3 反爬虫技术
  318. 思考与实践
  319. 第19章 图像识别与机器学习——字符型验证码自动识别
  320. 19.1 机器视觉与机器学习
  321. 19.1.1 机器视觉
  322. 19.1.2 机器学习
  323. 19.1.3 机器学习与神经网络
  324. 19.2 TensorFlow及其卷积神经网络
  325. 19.2.1 TensorFlow及其介绍
  326. 19.2.2 TensorFlow的程序举例
  327. 19.2.3 基于TensorFlow的卷积神经网络
  328. 19.3 字符型验证码的自动识别
  329. 19.3.1 字符型验证码
  330. 19.3.2 自动识别字符型验证码的两种方法
  331. 19.4 字符型验证码自动识别程序的实现
  332. 19.4.1 字符型验证码自动识别程序的算法设计
  333. 19.4.2 字符型验证码自动识别程序架构
  334. 19.4.3 字符型验证码自动识别程序
  335. 19.4.4 程序运行结果及其分析
  336. 19.5 归纳与总结
  337. 19.5.1 关于CNN模型
  338. 19.5.2 关于TensorFlow的一些问题
  339. 19.5.3 关于深度学习框架的问题
  340. 思考与实践
  341. 第20章 智能控制——基于串口控制的二极管花样显示
  342. 20.1 项目的设计目标
  343. 20.1.1 项目设计要求
  344. 20.1.2 串口及其设置
  345. 20.2 Pyboard开发板及其应用
  346. 20.2.1 Pyboard开发板
  347. 20.2.2 Pyboard开发板的安装
  348. 20.2.3 Pyboard开发板的控制方式
  349. 20.2.4 Pyboard开发板与上位机的串口通信测试
  350. 20.3 发光二极管显示板
  351. 20.4 项目的算法及其分析
  352. 20.4.1 上位机程序的算法
  353. 20.4.2 下位机程序的算法
  354. 20.5 项目的程序
  355. 20.5.1 上位机程序
  356. 20.5.2 下位机程序
  357. 20.6 实际运行效果及其分析
  358. 20.6.1 样机及其运行演示
  359. 20.6.2 程序运行要点
  360. 20.6.3 Pyboard开发板的资源
  361. 20.7 归纳与总结
  362. 思考与实践
  363. 第4篇 继续前进
  364. 第21章 程序的调试、测试与断言
  365. 21.1 程序的调试与测试
  366. 21.1.1 程序调试的方法
  367. 21.1.2 使用Python内置单步调试器(Pdb)调试程序
  368. 21.1.3 利用IDE集成开发环境调试程序
  369. 21.2 程序测试的方法
  370. 21.2.1 为什么要对程序进行测试
  371. 21.2.2 通过unittest实现一般测试
  372. 21.2.3 使用TestSuite进行测试
  373. 21.3 归纳与总结
  374. 思考与实践
  375. 第22章 Python程序的打包与发布
  376. 22.1 为什么要将程序打包
  377. 22.2 如何将程序打包
  378. 22.2.1 打包成.pyc文件
  379. 22.2.2 Python程序的运行过程
  380. 22.2.3 打包成.exe文件
  381. 22.3 归纳与总结
  382. 思考与实践
  383. 第23章 Python那些不得不说的事情
  384. 23.1 如何使程序更Pythonic
  385. 23.1.1 Python程序的基本原则
  386. 23.1.2 交换变量值(Swap Values)
  387. 23.1.3 合并字符串
  388. 23.1.4 使用关键字in
  389. 23.1.5 Python的True值(Truth Value)
  390. 23.1.6 enumerate—索引和元素(Index&Item)
  391. 23.1.7 Python方法中参数的默认值
  392. 23.2 迭代器
  393. 23.2.1 迭代器及其应用
  394. 23.2.2 列表生成式
  395. 23.3 生成器
  396. 23.3.1 生成器及其应用
  397. 23.3.2 yield及其使用
  398. 23.4 归纳与总结
  399. 思考与实践
  400. 后记
  401. 致谢
  402. 参考文献

FAQ

Is this book suitable for people with no programming experience at all?
Very much so. The book is designed for absolute beginners, starting from environment setup and using numerous everyday analogies and step-by-step cases to guide readers into programming thinking, avoiding the fear that abstract concepts can cause early on.
Are the cases in the book outdated or disconnected from real applications?
No. The cases emphasize fundamentals and representativeness and cover practical scenarios such as data processing, file management, and simple web scraping. Although specific library versions may change, the core logic and programming ideas are stable and general, laying a solid foundation for learning more specialized libraries later.
What level can I reach after finishing the book?
You will firmly grasp Python's core syntax and programming paradigms and be able to independently write scripts to solve small and medium-sized real problems, such as automating spreadsheet data processing, collecting web information, or building simple graphical interface programs, paving the way for further study in specialized areas such as data analysis and web development.

Comments

Find this book

This site is an index: you start “Search all sources” in your browser, and the entries it lists all point to third-party sites; please judge their availability yourself.

About the author

沈红卫 Author

Shen Hongwei: publicly available information is limited. What can be confirmed is that the author writes mainly on programming and design topics, with one work held in the collection, Python Full-Case Learning and Practice. As the title and its category suggest, the book is aimed at learners of Python programming and adopts a case-driven approach, weaving knowledge points into concrete practical tasks and emphasizing hands-on exercises and the development of programming thinking. Rather than merely listing syntax, this style of writing typically uses runnable examples to help readers understand language features and ways to solve common problems, making it suitable for beginners learning Python step by step and useful for those with some foundation who wish to fill gaps. Based on the available information, the author's educational background, professional experience and other works cannot be confirmed, but the book offers practical reference value in programming instruction and self-study, reflecting a writing orientation that values practice and case-based learning.

Top rated in the same category