<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>实用工具 on 老张开工了</title>
    <link>/%E5%AE%9E%E7%94%A8%E5%B7%A5%E5%85%B7/</link>
    <description>Recent content in 实用工具 on 老张开工了</description>
    <generator>Hugo</generator>
    <language>zh-cn</language>
    <lastBuildDate>Sun, 24 May 2026 00:00:00 +0000</lastBuildDate>
    <atom:link href="/%E5%AE%9E%E7%94%A8%E5%B7%A5%E5%85%B7/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>常用标准库精讲</title>
      <link>/posts/2026/05/standard-library/</link>
      <pubDate>Sun, 24 May 2026 00:00:00 +0000</pubDate>
      <guid>/posts/2026/05/standard-library/</guid>
      <description>Python 标准库的威力 Python 常被称为&amp;quot;自带电池&amp;quot;（Batteries Included）的语言，因为它的标准库涵盖了从数据结构到文件处理、从网络编程到数据序列化的方方面面。熟练掌握标准库可以让你在绝大多数场景下无需安装任何第三方包就能高效完成任务。&#xA;本章将精选最常用的标准库模块进行深入讲解。&#xA;collections：扩展数据结构 collections 模块提供了 Python 内置数据类型的升级版，在日常编码中使用频率极高。&#xA;defaultdict：带默认值的字典 from collections import defaultdict # 普通字典访问不存在的 key 会报 KeyError # defaultdict 自动为不存在的 key 创建默认值 # 统计字符出现次数 text = &amp;#34;hello world&amp;#34; counter = defaultdict(int) for char in text: counter[char] += 1 print(counter) # defaultdict(&amp;lt;class &amp;#39;int&amp;#39;&amp;gt;, {&amp;#39;h&amp;#39;: 1, &amp;#39;e&amp;#39;: 1, &amp;#39;l&amp;#39;: 3, &amp;#39;o&amp;#39;: 2, &amp;#39; &amp;#39;: 1, &amp;#39;w&amp;#39;: 1, &amp;#39;r&amp;#39;: 1, &amp;#39;d&amp;#39;: 1}) # 用列表作为默认值（分组） students = [ (&amp;#34;A班&amp;#34;, &amp;#34;小明&amp;#34;), (&amp;#34;B班&amp;#34;, &amp;#34;小红&amp;#34;), (&amp;#34;A班&amp;#34;, &amp;#34;小刚&amp;#34;), (&amp;#34;B班&amp;#34;, &amp;#34;小丽&amp;#34;), ] classes = defaultdict(list) for class_name, student in students: classes[class_name].</description>
    </item>
  </channel>
</rss>
