<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Standard-Library on 每日拍拍</title>
    <link>https://dailypypy.org/tags/standard-library/</link>
    <description>Recent content in Standard-Library on 每日拍拍</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>zh-tw</language>
    <copyright>© 2026 每日拍拍</copyright>
    <lastBuildDate>Sat, 16 May 2026 10:03:00 +0800</lastBuildDate><atom:link href="https://dailypypy.org/tags/standard-library/index.xml" rel="self" type="application/rss+xml" />
    <follow_challenge>
      <feedId>155076163427069952</feedId>
      <userId>154825760438254592</userId>
    </follow_challenge>
    
    
    <item>
      <title>Python tempfile 實戰：安全建立暫存檔案、目錄與測試資料</title>
      <link>https://dailypypy.org/learn/python-tempfile/</link>
      <pubDate>Sat, 16 May 2026 10:03:00 +0800</pubDate>
      
      <guid>https://dailypypy.org/learn/python-tempfile/</guid>
      <description>&lt;!---
1440x768
prompt: masterpiece, best quality, highres, clean anime illustration, japanese anime style, soft shading, flat color design, 1girl, black hair, green eyes, white off-shoulder shirt, black short skirt, side profile, looking over shoulder, holding a small folder, gentle confident smile, looking at viewer, soft sage green background, subtle floating file and folder shapes without text, neat composition, detailed eyes, cute and smart vibe, minimal background, polished illustration, no text
negative prompt: worst quality, bad eye, bad hand, extra limbs, manga, multiple views, monochrome, text, signature
preflight: candidate python-tempfile is distinct from python-pathlib, which focuses on path objects, python-pytest, which focuses on test framework features, and streamlit-deploy-secrets, which only mentions tempfile briefly for upload handling. This post focuses on standard-library temporary file and directory lifecycle, secure creation, cleanup, and practical scratch-space workflows.
---&gt;

&lt;h2 class=&#34;relative group&#34;&gt;一. 前言：暫存檔不是隨便丟到 /tmp 就好 
    &lt;div id=&#34;一-前言暫存檔不是隨便丟到-tmp-就好&#34; class=&#34;anchor&#34;&gt;&lt;/div&gt;
    
    &lt;span
        class=&#34;absolute top-0 w-6 transition-opacity opacity-0 ltr:-left-6 rtl:-right-6 not-prose group-hover:opacity-100&#34;&gt;
        &lt;a class=&#34;group-hover:text-primary-300 dark:group-hover:text-neutral-700&#34;
            style=&#34;text-decoration-line: none !important;&#34; href=&#34;#%e4%b8%80-%e5%89%8d%e8%a8%80%e6%9a%ab%e5%ad%98%e6%aa%94%e4%b8%8d%e6%98%af%e9%9a%a8%e4%be%bf%e4%b8%9f%e5%88%b0-tmp-%e5%b0%b1%e5%a5%bd&#34; aria-label=&#34;定位點&#34;&gt;#&lt;/a&gt;
    &lt;/span&gt;        
    
&lt;/h2&gt;
&lt;p&gt;寫 Python 的時候，我們常常需要一個「先放一下」的地方。 例如把 API 回來的大檔案先落地。 例如把使用者上傳的 CSV 轉成乾淨版本。 例如測試時需要建立一組假的資料夾。 例如 CLI 工具產生中間報表，最後才輸出成正式檔案。 很多人第一反應是這樣：&lt;/p&gt;</description>
      <media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://dailypypy.org/learn/python-tempfile/featured.png" />
    </item>
    
    <item>
      <title>Python zoneinfo 實戰：時區、DST 與排程時間處理完全攻略</title>
      <link>https://dailypypy.org/learn/python-zoneinfo/</link>
      <pubDate>Fri, 15 May 2026 12:12:00 +0800</pubDate>
      
      <guid>https://dailypypy.org/learn/python-zoneinfo/</guid>
      <description>&lt;!---
1440x768
prompt: masterpiece, best quality, highres, clean anime illustration, japanese anime style, soft shading, flat color design, 1girl, black hair, green eyes, white off-shoulder shirt, black short skirt, from above, leaning forward, curious bright smile, looking at viewer, pale coral background, subtle floating clocks and globe shapes without text, neat composition, detailed eyes, cute and smart vibe, minimal background, polished illustration, no text
negative prompt: worst quality, bad eye, bad hand, extra limbs, manga, multiple views, monochrome, text, signature
---&gt;

&lt;h2 class=&#34;relative group&#34;&gt;一. 前言：時間看起來簡單，直到它跨過時區 
    &lt;div id=&#34;一-前言時間看起來簡單直到它跨過時區&#34; class=&#34;anchor&#34;&gt;&lt;/div&gt;
    
    &lt;span
        class=&#34;absolute top-0 w-6 transition-opacity opacity-0 ltr:-left-6 rtl:-right-6 not-prose group-hover:opacity-100&#34;&gt;
        &lt;a class=&#34;group-hover:text-primary-300 dark:group-hover:text-neutral-700&#34;
            style=&#34;text-decoration-line: none !important;&#34; href=&#34;#%e4%b8%80-%e5%89%8d%e8%a8%80%e6%99%82%e9%96%93%e7%9c%8b%e8%b5%b7%e4%be%86%e7%b0%a1%e5%96%ae%e7%9b%b4%e5%88%b0%e5%ae%83%e8%b7%a8%e9%81%8e%e6%99%82%e5%8d%80&#34; aria-label=&#34;定位點&#34;&gt;#&lt;/a&gt;
    &lt;/span&gt;        
    
&lt;/h2&gt;
&lt;p&gt;寫程式處理時間，很容易一開始覺得沒什麼。&lt;code&gt;datetime.now()&lt;/code&gt; 一叫，資料庫一存，畫面一顯示，事情好像就結束了。
然後某天使用者在紐約，伺服器在東京，資料庫存 UTC，排程又遇到夏令時間。拍拍君通常會在這種時候默默放下咖啡。
因為問題不是「怎麼取得現在時間」，而是這個時間到底屬於哪個時區、是不是 UTC、要顯示給誰看、遇到 DST 時凌晨兩點到底存在不存在。
Python 3.9 開始內建 &lt;code&gt;zoneinfo&lt;/code&gt;，讓我們不用額外安裝 &lt;code&gt;pytz&lt;/code&gt;，就能使用 IANA time zone database，例如 &lt;code&gt;Asia/Taipei&lt;/code&gt;、&lt;code&gt;America/New_York&lt;/code&gt;、&lt;code&gt;Europe/London&lt;/code&gt;。
今天這篇會很務實地處理幾個場景：&lt;/p&gt;</description>
      
    </item>
    
  </channel>
</rss>
