
Python 进阶
Gozen Sanji
这个作者很懒,什么都没留下…
展开
-
Python CookBook —— Chapter 7 (个人笔记)
文章目录Chap 7 函数7.1 可接受任意数量参数的函数 --- *args & **kwargs7.2 只接受关键字参数的函数 --- 位于 * or *args 后の强制关键字参数7.3 给函数参数增加元信息 --- 函数参数注解 & .__annotations__ 属性7.4 返回多个值的函数 --- return x, y, z7.5 定义有默认参数的函数 --- 带默认值的参数, 使用 None 作为默认值, is 操作符7.6 定义匿名或内联函数 --- lambda Exp原创 2020-10-12 16:02:18 · 217 阅读 · 0 评论 -
Python CookBook —— Chapter 6 (个人笔记)
文章目录Chap 6 数据编码和处理6.1 读写 CSV 数据 --- csv.reader(), csv.writer(), csv.DictReader(), csv.DictWriter()6.2 读写 JSON 数据 --- dumps(), loads(), dump(), load(), pprint() & indent 参数6.3 解析简单的 XML 数据 --- xml.etree.ElementTree.parse(), find(), iterfind(), findtext(原创 2020-09-25 10:27:12 · 301 阅读 · 0 评论 -
Python CookBook —— Chapter 5 (个人笔记)
文章目录Chap 5 文件与 IO5.1 读写文本数据 --- open() 的各种模式及 encoding & errors 参数, sys.getdefaultencoding()5.2 打印输出至文件中 --- print() 函数的关键字参数 file5.3 使用其他分隔符或行终止符打印 --- print() 的 sep & end 参数5.4 读写字节数据 --- open() 函数的 'rb' / 'wb' 参数, encode, decode5.5 文件不存在才能写入 ---原创 2020-09-18 11:25:08 · 260 阅读 · 0 评论 -
Python CookBook —— Chapter 4 (个人笔记)
文章目录Chap 4 迭代器与生成器4.1 手动遍历迭代器 --- next(), iter(), StopIteration4.2 代理迭代 --- __ iter __()4.3 使用生成器创建新的迭代模式 --- create a generator through a yield statement4.4 实现迭代器协议 --- ???4.5 反向迭代 --- reversed() & __ reversed __() in class definition4.6 带有外部状态的生成器函数原创 2020-09-18 11:24:50 · 256 阅读 · 0 评论 -
Python CookBook —— Chapter 3 (个人笔记)
文章目录Chap 3 数字日期和时间3.1 数字的四舍五入 --- round(value, ndigits)3.2 执行精确的浮点数运算 --- Decimal(str) / localcontext() / math.fsum()3.3 数字的格式化输出 --- format() on floats & Decimal Obj3.4 2 / 8 / 16 进制整数 --- bin() / oct() / hex() & format() / int()3.5 字节到大整数的打包与解包 -原创 2020-09-04 09:10:28 · 366 阅读 · 0 评论 -
Python CookBook —— Chapter 2 (个人笔记)
文章目录Chap 2 字符串和文本2.1 使用多个界定符分割字符串 --- re.split() & 捕获分组 & 非捕获分组2.2 字符串开头或结尾匹配 --- startswith / endswith2.3 用 Shell 通配符匹配字符串 --- fnmatch & fnmatchcase2.4 字符串匹配和搜索 --- str.find / match & findall & finditer2.5 字符串搜索和替换 --- re.sub & re.原创 2020-09-04 09:08:37 · 247 阅读 · 0 评论 -
Python CookBook —— Chapter 1 (个人笔记)
文章目录Chap 1 数据结构与算法1.1 解压序列赋值给多个变量1.2 解压可迭代对象赋值给多个变量1.3 保留最后 N 个元素 --- collections.deque1.4 查找最大或最小的 N 个元素 --- heapq.nlargest/nsmallest1.5 实现一个优先级队列 --- heapq.heappush/heappop1.6 字典中的键映射多个值 --- collections.defaultdict1.7 字典排序 --- collections.OrderedDict1.8原创 2020-08-17 15:38:45 · 296 阅读 · 0 评论