<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[AugustusHsu's Blog]]></title><description><![CDATA[Strike the iron while it is hot.]]></description><link>https://ghost.augustushsu.com/</link><image><url>https://ghost.augustushsu.com/favicon.png</url><title>AugustusHsu&apos;s Blog</title><link>https://ghost.augustushsu.com/</link></image><generator>Ghost 5.59</generator><lastBuildDate>Fri, 03 Apr 2026 20:49:07 GMT</lastBuildDate><atom:link href="https://ghost.augustushsu.com/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[VS Code Note 02]]></title><description><![CDATA[<h1 id="%E7%94%A8vscode%E9%96%8B%E7%99%BCc">&#x7528;VSCode&#x958B;&#x767C;C++</h1>
<p>&#x5728;&#x73FE;&#x4EE3;&#x8EDF;&#x9AD4;&#x958B;&#x767C;&#x4E2D;&#xFF0C;&#x8DE8;&#x5E73;&#x53F0;&#x958B;&#x767C;&#x7684;&#x91CD;&#x8981;&#x6027;&#x65E5;&#x76CA;&#x589E;&#x9577;&#xFF0C;&#x5C24;&#x5176;&#x5728; C++ &#x9818;&#x57DF;&#xFF0C;&#x7531;&#x65BC;&#x5176;&#x9AD8;&#x6548;&#x80FD;&#x548C;&#x9748;&#x6D3B;&#x6027;&#xFF0C;&#x4F7F;&#x5176;&#x6210;&#x70BA;</p>]]></description><link>https://ghost.augustushsu.com/vscode-note02/</link><guid isPermaLink="false">66fb6d2cbd8ad405433c4552</guid><category><![CDATA[VSCode-Note]]></category><dc:creator><![CDATA[AugustusHsu]]></dc:creator><pubDate>Sun, 03 Nov 2024 12:00:19 GMT</pubDate><media:content url="https://ghost.augustushsu.com/content/images/2024/10/vscode-note02-cover-2.png" medium="image"/><content:encoded><![CDATA[<h1 id="%E7%94%A8vscode%E9%96%8B%E7%99%BCc">&#x7528;VSCode&#x958B;&#x767C;C++</h1>
<img src="https://ghost.augustushsu.com/content/images/2024/10/vscode-note02-cover-2.png" alt="VS Code Note 02"><p>&#x5728;&#x73FE;&#x4EE3;&#x8EDF;&#x9AD4;&#x958B;&#x767C;&#x4E2D;&#xFF0C;&#x8DE8;&#x5E73;&#x53F0;&#x958B;&#x767C;&#x7684;&#x91CD;&#x8981;&#x6027;&#x65E5;&#x76CA;&#x589E;&#x9577;&#xFF0C;&#x5C24;&#x5176;&#x5728; C++ &#x9818;&#x57DF;&#xFF0C;&#x7531;&#x65BC;&#x5176;&#x9AD8;&#x6548;&#x80FD;&#x548C;&#x9748;&#x6D3B;&#x6027;&#xFF0C;&#x4F7F;&#x5176;&#x6210;&#x70BA;&#x8A31;&#x591A;&#x61C9;&#x7528;&#x7A0B;&#x5F0F;&#x7684;&#x9996;&#x9078;&#x8A9E;&#x8A00;&#x3002;&#x5728;&#x9019;&#x6A23;&#x7684;&#x80CC;&#x666F;&#x4E0B;&#xFF0C;Visual Studio Code&#x6191;&#x85C9;&#x5176;&#x8F15;&#x91CF;&#x3001;&#x8DE8;&#x5E73;&#x53F0;&#x3001;&#x529F;&#x80FD;&#x5F37;&#x5927;&#x7684;&#x7279;&#x9EDE;&#xFF0C;&#x6210;&#x70BA;&#x8D8A;&#x4F86;&#x8D8A;&#x591A;&#x958B;&#x767C;&#x8005;&#x7684;&#x9996;&#x9078;&#x958B;&#x767C;&#x74B0;&#x5883;&#x3002;VSCode&#x4E0D;&#x50C5;&#x652F;&#x63F4;&#x591A;&#x7A2E;&#x8A9E;&#x8A00;&#xFF0C;&#x9084;&#x80FD;&#x5920;&#x900F;&#x904E;&#x64F4;&#x5145;&#x5957;&#x4EF6;&#x5BE6;&#x73FE;&#x5982; IDE &#x822C;&#x7684;&#x958B;&#x767C;&#x9AD4;&#x9A57;&#xFF0C;&#x4E26;&#x63D0;&#x4F9B;&#x8207; Git &#x6574;&#x5408;&#x3001;&#x9060;&#x7AEF;&#x958B;&#x767C;&#x7B49;&#x529F;&#x80FD;&#xFF0C;&#x4F7F;&#x958B;&#x767C;&#x8005;&#x80FD;&#x66F4;&#x9AD8;&#x6548;&#x5730;&#x7BA1;&#x7406;&#x8DE8;&#x5E73;&#x53F0;&#x5C08;&#x6848;&#x3002;</p>
<p>&#x5728;&#x5BE6;&#x969B;&#x958B;&#x767C;&#x4E2D;&#xFF0C;&#x6839;&#x64DA;&#x5C08;&#x6848;&#x9700;&#x6C42;&#xFF0C;&#x958B;&#x767C;&#x8005;&#x53EF;&#x80FD;&#x9700;&#x8981;&#x7DE8;&#x8B6F;&#x51FA;&#x5C0D;&#x61C9;&#x4E0D;&#x540C;&#x4F5C;&#x696D;&#x7CFB;&#x7D71;&#x7684;&#x52D5;&#x614B;&#x9023;&#x7D50;&#x5EAB; (DLL)&#x3002;&#x5C0D;&#x65BC;Windows&#x7CFB;&#x7D71;&#xFF0C;&#x53EF;&#x4EE5;&#x900F;&#x904E;MinGW (Minimalist GNU for Windows) &#x4F86;&#x7DE8;&#x8B6F;DLL&#xFF0C;&#x800C;&#x5C0D;&#x65BC;Linux&#x7CFB;&#x7D71;&#xFF0C;&#x5247;&#x53EF;&#x4EE5;&#x5229;&#x7528;WSL&#x7D50;&#x5408;GCC&#x4F86;&#x751F;&#x6210;&#x9069;&#x7528;&#x65BC;Linux&#x7684;&#x52D5;&#x614B;&#x5EAB;&#x3002;&#x9019;&#x6A23;&#x7684;&#x67B6;&#x69CB;&#x4F7F;&#x5F97;&#x958B;&#x767C;&#x8005;&#x80FD;&#x5920;&#x5728;&#x540C;&#x4E00;&#x500B;&#x74B0;&#x5883;&#x4E2D;&#x540C;&#x6642;&#x958B;&#x767C;&#x4E26;&#x6E2C;&#x8A66;&#x91DD;&#x5C0D;&#x4E0D;&#x540C;&#x5E73;&#x53F0;&#x7684;&#x7A0B;&#x5F0F;&#x78BC;&#xFF0C;&#x5F9E;&#x800C;&#x63D0;&#x9AD8;&#x4E86;&#x5DE5;&#x4F5C;&#x6548;&#x7387;&#x4E26;&#x6E1B;&#x5C11;&#x4E86;&#x74B0;&#x5883;&#x5207;&#x63DB;&#x6240;&#x5E36;&#x4F86;&#x7684;&#x9EBB;&#x7169;&#x3002;</p>
<h2 id="%E5%AE%89%E8%A3%9D%E7%B7%A8%E8%AD%AF%E5%99%A8">&#x5B89;&#x88DD;&#x7DE8;&#x8B6F;&#x5668;</h2>
<p>&#x5B89;&#x88DD;&#x65B9;&#x5F0F;&#x53EF;&#x4EE5;&#x6309;&#x7167;VSCode&#x7684;&#x6587;&#x6A94;&#x8AAA;&#x660E;&#x4F86;&#x5B89;&#x88DD;&#xFF0C;&#x6587;&#x6A94;&#x4E0A;&#x5728;Windows&#x4E0A;&#x6709;&#x5206;&#x5225;&#x4ECB;&#x7D39;&#x4F7F;&#x7528;<a href="https://vscode.dev.org.tw/docs/cpp/config-mingw?ref=ghost.augustushsu.com">MinGW</a>&#x3001;<a href="https://vscode.dev.org.tw/docs/cpp/config-wsl?ref=ghost.augustushsu.com">WSL</a>&#x548C;<a href="https://vscode.dev.org.tw/docs/cpp/config-msvc?ref=ghost.augustushsu.com">Microsoft Visual C++ (MSVC)</a> &#x9019;&#x4E09;&#x7A2E;&#x65B9;&#x5F0F;&#x4F86;&#x5B89;&#x88DD;&#x7DE8;&#x8B6F;&#x5668;&#x3002;</p>
<p>&#x5728;&#x5B89;&#x88DD;&#x4E4B;&#x524D;&#x8981;&#x8A18;&#x5F97;&#x5728;VSCode&#x64F4;&#x5145;&#x5957;&#x4EF6;&#x4E2D;&#x5B89;&#x88DD;C/C++&#x64F4;&#x5145;&#x529F;&#x80FD;&#x7684;&#x5957;&#x4EF6;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/10/image-13.png" class="kg-image" alt="VS Code Note 02" loading="lazy" width="405" height="88"></figure>
<h3 id="mingw">MinGW</h3>
<p>&#x53EF;&#x4EE5;&#x6309;&#x7167;&#x6587;&#x6A94;&#x4E0A;&#x6240;&#x63A8;&#x85A6;&#x7684;&#x65B9;&#x5F0F;&#xFF0C;&#x900F;&#x904E;<a href="https://www.msys2.org/?ref=ghost.augustushsu.com">MSYS2</a>&#x4F86;&#x5B89;&#x88DD;MinGW&#xFF0C;&#x5B89;&#x88DD;&#x597D;MSYS2&#x5F8C;&#x6253;&#x958B;&#x7D42;&#x7AEF;&#x57F7;&#x884C;&#x4E0B;&#x9762;&#x9019;&#x6BB5;</p>
<pre><code class="language-bash">pacman -S --needed base-devel mingw-w64-ucrt-x86_64-toolchain</code></pre>
<p>&#x6309;&#x4E0B;<code>Enter</code>&#x63A5;&#x53D7;&#xA0;<code>toolchain</code>&#xA0;&#x7FA4;&#x7D44;&#x4E2D;&#x7684;&#x9810;&#x8A2D;&#x5957;&#x4EF6;&#x6578;&#x91CF;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/10/image-1.png" class="kg-image" alt="VS Code Note 02" loading="lazy" width="1098" height="242" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/10/image-1.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2024/10/image-1.png 1000w, https://ghost.augustushsu.com/content/images/2024/10/image-1.png 1098w" sizes="(min-width: 720px) 720px"></figure>
<p>&#x76F4;&#x63A5;&#x5B89;&#x88DD;&#x5C31;&#x53EF;&#x4EE5;&#x4E86;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/10/image-2.png" class="kg-image" alt="VS Code Note 02" loading="lazy" width="1105" height="817" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/10/image-2.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2024/10/image-2.png 1000w, https://ghost.augustushsu.com/content/images/2024/10/image-2.png 1105w" sizes="(min-width: 720px) 720px"></figure>
<p>&#x4E5F;&#x53EF;&#x4EE5;&#x900F;&#x904E;<a href="https://sourceforge.net/projects/mingw/?ref=ghost.augustushsu.com">MinGW Installation Manager Setup Tool</a>&#x6216;&#x662F;<a href="https://www.mingw-w64.org/downloads/?ref=ghost.augustushsu.com">MinGW</a>&#x7684;&#x7DB2;&#x7AD9;&#x4F86;&#x5B89;&#x88DD;MinGW&#xFF0C;&#x5B89;&#x88DD;&#x5F8C;&#x5C07;<code>C:\msys64\ucrt64\bin</code>&#x52A0;&#x5165;&#x74B0;&#x5883;&#x8B8A;&#x6578;&#x4E2D;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/10/image-10.png" class="kg-image" alt="VS Code Note 02" loading="lazy" width="523" height="494"></figure>
<p>&#x52A0;&#x5165;&#x74B0;&#x5883;&#x8B8A;&#x6578;&#x5F8C;&#xFF0C;&#x53EF;&#x4EE5;&#x5728;terminal&#x4E0A;&#x57F7;&#x884C;&#x4EE5;&#x4E0B;&#x6307;&#x4EE4;&#x78BA;&#x5B9A;&#x53EF;&#x4EE5;&#x57F7;&#x884C;:</p>
<pre><code class="language-bash">gcc --version
g++ --version
gdb --version</code></pre>
<p>&#x5728;VSCode&#x4E2D;&#x9EDE;&#x9078;&#x53F3;&#x4E0A;&#x89D2;<code>&#x57F7;&#x884C;C/C++&#x6A94;&#x6848;</code>&#x5F8C;&#x9078;&#x64C7;&#x7528;g++&#x4F86;&#x5EFA;&#x7F6E;&#x53CA;&#x5075;&#x932F;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/10/image-3.png" class="kg-image" alt="VS Code Note 02" loading="lazy" width="712" height="219" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/10/image-3.png 600w, https://ghost.augustushsu.com/content/images/2024/10/image-3.png 712w"></figure>
<h3 id="wsl">WSL</h3>
<p>&#x5728;Windows&#x7684;WSL&#x5B89;&#x88DD;&#x5B8C;Ubuntu&#x5F8C;&#xFF0C;&#x958B;&#x555F;WSL&#x7684;Bash Shell&#x66F4;&#x65B0;&#x4E00;&#x4E0B;Ubuntu&#x518D;&#x5B89;&#x88DD;GNU&#x7DE8;&#x8B6F;&#x5668;&#x5DE5;&#x5177;&#x548C;GDB&#x5075;&#x932F;&#x7A0B;&#x5F0F;:</p>
<pre><code class="language-bash">sudo apt-get update &amp;&amp; sudo apt-get dist-upgrade

sudo apt-get install build-essential gdb</code></pre>
<p>&#x53EF;&#x4EE5;&#x5C0B;&#x627E;g++&#x548C;gdb&#x4F86;&#x9A57;&#x8B49;&#x5B89;&#x88DD;&#x662F;&#x5426;&#x6210;&#x529F;&#x3002;&#x5982;&#x679C;<code>whereis</code>&#x547D;&#x4EE4;&#x672A;&#x50B3;&#x56DE;&#x6A94;&#x6848;&#x540D;&#x7A31;&#xFF0C;&#x8ACB;&#x5617;&#x8A66;&#x518D;&#x6B21;&#x57F7;&#x884C;&#x66F4;&#x65B0;&#x547D;&#x4EE4;:</p>
<pre><code class="language-bash">whereis g++
whereis gdb</code></pre>
<p>&#x5B89;&#x88DD;WSL&#x7684;&#x5EF6;&#x4F38;&#x6A21;&#x7D44;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/10/image-5.png" class="kg-image" alt="VS Code Note 02" loading="lazy" width="316" height="88"></figure>
<p>&#x5B89;&#x88DD;&#x5B8C;&#x5F8C;&#x53EF;&#x4EE5;&#x5F9E;VSCode&#x7684;&#x5DE6;&#x4E0B;&#x89D2;&#x9023;&#x7DDA;&#x5230;WSL&#x88E1;&#x9762;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/10/image-4.png" class="kg-image" alt="VS Code Note 02" loading="lazy" width="276" height="133"></figure>
<p>&#x5728;Ubuntu&#x7684;terminal&#x4E2D;&#x57F7;&#x884C;&#x4EE5;&#x4E0B;&#x6307;&#x4EE4;&#xFF0C;&#x78BA;&#x5B9A;&#x53EF;&#x4EE5;&#x57F7;&#x884C;:</p>
<pre><code class="language-bash">whereis g++
whereis gdb</code></pre>
<p>&#x5728;VSCode&#x4E2D;&#x9EDE;&#x9078;&#x53F3;&#x4E0A;&#x89D2;<code>&#x57F7;&#x884C;C/C++&#x6A94;&#x6848;</code>&#x5F8C;&#x9078;&#x64C7;&#x4E00;&#x6A23;&#x7528;g++&#x4F86;&#x5EFA;&#x7F6E;&#x53CA;&#x5075;&#x932F;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/10/image-6.png" class="kg-image" alt="VS Code Note 02" loading="lazy" width="716" height="188" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/10/image-6.png 600w, https://ghost.augustushsu.com/content/images/2024/10/image-6.png 716w"></figure>
<h3 id="msvc">MSVC</h3>
<p>&#x5982;&#x679C;&#x9078;&#x64C7;&#x4E0D;&#x5B89;&#x88DD;&#x5B8C;&#x6574;Visual Studio IDE&#x7684;&#x60C5;&#x6CC1;&#x4E0B;&#xFF0C;&#x53EF;&#x4EE5;&#x5728;<a href="https://visualstudio.microsoft.com/zh-hant/downloads/?ref=ghost.augustushsu.com">Visual Studio</a>&#x6700;&#x4E0B;&#x9762;&#x4E0B;&#x8F09;Build Tools for Visual Studio 2022:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/10/image-7.png" class="kg-image" alt="VS Code Note 02" loading="lazy" width="1458" height="248" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/10/image-7.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2024/10/image-7.png 1000w, https://ghost.augustushsu.com/content/images/2024/10/image-7.png 1458w" sizes="(min-width: 720px) 720px"></figure>
<p>&#x52FE;&#x9078;<strong>&#x4F7F;&#x7528; C++ &#x9032;&#x884C;&#x684C;&#x9762;&#x958B;&#x767C;</strong>&#x7684;&#x9078;&#x9805;&#xFF0C;&#x4E26;&#x9078;&#x53D6;&#x5B89;&#x88DD;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/10/image-8.png" class="kg-image" alt="VS Code Note 02" loading="lazy" width="1231" height="709" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/10/image-8.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2024/10/image-8.png 1000w, https://ghost.augustushsu.com/content/images/2024/10/image-8.png 1231w" sizes="(min-width: 720px) 720px"></figure>
<p>&#x6253;&#x958B;<code>Developer Command Prompt</code>&#xFF0C;&#x57F7;&#x884C;<code>cl</code>&#x78BA;&#x5B9A;&#x53EF;&#x4EE5;&#x57F7;&#x884C;&#xFF0C;&#x4E4B;&#x5F8C;&#x5982;&#x679C;&#x8981;&#x4F7F;&#x7528;cl&#x4F86;&#x7DE8;&#x8B6F;&#x57F7;&#x884C;&#xFF0C;&#x8981;&#x8A18;&#x5F97;&#x4F7F;&#x7528;&#x9019;&#x500B;terminal&#x8F38;&#x5165;<code>code</code>&#x4F86;&#x555F;&#x52D5;VSCode&#x624D;&#x80FD;&#x7DE8;&#x8B6F;&#x57F7;&#x884C;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/10/image-12.png" class="kg-image" alt="VS Code Note 02" loading="lazy" width="772" height="725" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/10/image-12.png 600w, https://ghost.augustushsu.com/content/images/2024/10/image-12.png 772w" sizes="(min-width: 720px) 720px"></figure>
<p>&#x5728;VSCode&#x4E2D;&#x9EDE;&#x9078;&#x53F3;&#x4E0A;&#x89D2;<code>&#x57F7;&#x884C;C/C++&#x6A94;&#x6848;</code>&#x5F8C;&#x9078;&#x64C7;&#x4E00;&#x6A23;<code>cl.exe</code>&#x4F86;&#x5EFA;&#x7F6E;&#x53CA;&#x5075;&#x932F;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/10/image-9.png" class="kg-image" alt="VS Code Note 02" loading="lazy" width="716" height="215" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/10/image-9.png 600w, https://ghost.augustushsu.com/content/images/2024/10/image-9.png 716w"></figure>
<p>&#x5982;&#x679C;&#x4E0D;&#x5728;<code>Developer Command Prompt</code>&#x4E2D;&#x4F86;&#x555F;&#x52D5;VSCode&#x7684;&#x8A71;&#xFF0C;&#x9700;&#x8981;&#x5728;<code>tasks.json</code>&#x7684;task&#x524D;&#x65B0;&#x589E;&#x4EE5;&#x4E0B;&#x7684;&#x6BB5;&#x843D;:</p>
<pre><code class="language-json">{
  &quot;version&quot;: &quot;2.0.0&quot;,
  &quot;windows&quot;: {
    &quot;options&quot;: {
      &quot;shell&quot;: {
        &quot;executable&quot;: &quot;cmd.exe&quot;,
        &quot;args&quot;: [
          &quot;/C&quot;,
          // The path to VsDevCmd.bat depends on the version of Visual Studio you have installed.
          &quot;\&quot;C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/Tools/VsDevCmd.bat\&quot;&quot;,
          &quot;&amp;&amp;&quot;
        ]
      }
    }
  },
  &quot;tasks&quot;: [
    ...
  ]
}
</code></pre>
<p><code>VsDevCmd.bat</code>&#x7684;&#x8DEF;&#x5F91;&#x53EF;&#x80FD;&#x6703;&#x6709;&#x6240;&#x4E0D;&#x540C;&#xFF0C;&#x53EF;&#x4EE5;&#x900F;&#x904E;<code>dir &quot;\VsDevCmd*&quot; /s</code>&#x4F86;&#x627E;&#x5230;<code>VsDevCmd.bat</code>&#x7684;&#x7684;&#x4F4D;&#x7F6E;&#x3002;</p>
<h2 id="tasksjson">tasks.json</h2>
<p><code>tasks.json</code>&#x4E3B;&#x8981;&#x7528;&#x4F86;&#x5B9A;&#x7FA9;&#x57F7;&#x884C;&#x5404;&#x7A2E;&#x4EFB;&#x52D9;&#x7684;&#x914D;&#x7F6E;&#xFF0C;&#x9019;&#x4E9B;&#x4EFB;&#x52D9;&#x901A;&#x5E38;&#x662F;&#x6307;<strong>&#x7DE8;&#x8B6F;&#x3001;&#x6E05;&#x7406;&#x3001;&#x6253;&#x5305;&#x3001;&#x57F7;&#x884C;&#x81EA;&#x52D5;&#x5316;&#x6E2C;&#x8A66;</strong>&#x7B49;&#x64CD;&#x4F5C;&#x3002;VSCode&#x900F;&#x904E;&#x9019;&#x500B;&#x6A94;&#x6848;&#x4F86;&#x544A;&#x8A34;&#x7DE8;&#x8B6F;&#x5668;&#x6216;&#x5176;&#x4ED6;&#x5DE5;&#x5177;&#x8A72;&#x5982;&#x4F55;&#x904B;&#x884C;&#xFF0C;&#x4F8B;&#x5982;&#x4F7F;&#x7528;&#x54EA;&#x500B;&#x7DE8;&#x8B6F;&#x5668;&#x3001;&#x8F38;&#x5165;&#x548C;&#x8F38;&#x51FA;&#x6A94;&#x6848;&#x7684;&#x4F4D;&#x7F6E;&#x3001;&#x7DE8;&#x8B6F;&#x9078;&#x9805;&#x7B49;&#x3002;</p>
<p>&#x5728;&#x7B2C;&#x4E00;&#x6B21;&#x57F7;&#x884C;&#x7A0B;&#x5F0F;&#x6642;&#xFF0C;C++&#x64F4;&#x5145;&#x529F;&#x80FD;&#x6703;&#x5EFA;&#x7ACB;&#x4E00;&#x500B;<code>tasks.json</code>&#x6A94;&#x6848;&#xFF0C;&#x53EF;&#x4EE5;&#x5728;&#x5C08;&#x6848;&#x7684;<code>.vscode</code>&#x8CC7;&#x6599;&#x593E;&#x4E2D;&#x627E;&#x5230;&#x5B83;&#xFF0C;<code>tasks.json</code>&#x6703;&#x5132;&#x5B58;<strong>&#x5EFA;&#x7F6E;&#x7D44;&#x614B;</strong>&#xFF0C;&#x65B0;<code>tasks.json</code>&#x6A94;&#x6848;&#x61C9;&#x8A72;&#x985E;&#x4F3C;&#x65BC;&#x4EE5;&#x4E0B;&#x7684;JSON:</p>
<pre><code class="language-json">{
    &quot;tasks&quot;: [
        {
            &quot;type&quot;: &quot;cppbuild&quot;,
            &quot;label&quot;: &quot;C/C++: g++.exe &#x5EFA;&#x7F6E;&#x4F7F;&#x7528;&#x4E2D;&#x6A94;&#x6848;&quot;,
            &quot;command&quot;: &quot;C:\\msys64\\ucrt64\\bin\\g++.exe&quot;,
            &quot;args&quot;: [
                &quot;-fdiagnostics-color=always&quot;,
                &quot;-g&quot;,
                &quot;${file}&quot;,
                &quot;-o&quot;,
                &quot;${fileDirname}\\${fileBasenameNoExtension}.exe&quot;
            ],
            &quot;options&quot;: {
                &quot;cwd&quot;: &quot;${fileDirname}&quot;
            },
            &quot;problemMatcher&quot;: [
                &quot;$gcc&quot;
            ],
            &quot;group&quot;: {
                &quot;kind&quot;: &quot;build&quot;,
                &quot;isDefault&quot;: true
            },
            &quot;detail&quot;: &quot;&#x5075;&#x932F;&#x5DE5;&#x5177;&#x7522;&#x751F;&#x7684;&#x5DE5;&#x4F5C;&#x3002;&quot;
        }
    ],
    &quot;version&quot;: &quot;2.0.0&quot;
}</code></pre>
<p>&#x9019;&#x662F;VSCode&#x4E2D;<code>tasks.json</code>&#x6587;&#x4EF6;&#x7684;&#x4E00;&#x500B;&#x8A2D;&#x5B9A;&#x7BC4;&#x4F8B;&#xFF0C;&#x5B83;&#x4E3B;&#x8981;&#x8CA0;&#x8CAC;&#x914D;&#x7F6E;&#x7DE8;&#x8B6F;C/C++&#x7A0B;&#x5F0F;&#x7684;&#x4EFB;&#x52D9;&#x3002;</p>
<ul><li><code>&quot;tasks&quot;</code>: &#x9019;&#x500B;&#x9375;&#x662F;&#x4EFB;&#x52D9;&#x5217;&#x8868;&#xFF0C;&#x88E1;&#x9762;&#x53EF;&#x4EE5;&#x5B9A;&#x7FA9;&#x591A;&#x500B;&#x4EFB;&#x52D9; (tasks)&#xFF0C;&#x6BCF;&#x500B;&#x4EFB;&#x52D9;&#x90FD;&#x8868;&#x793A;&#x4E00;&#x500B;&#x5177;&#x9AD4;&#x7684;&#x64CD;&#x4F5C;&#xFF0C;&#x4F8B;&#x5982;&#x7DE8;&#x8B6F;&#x7A0B;&#x5F0F;&#x78BC;&#x3002;</li><li><code>&quot;version&quot;: &quot;2.0.0&quot;</code>: &#x9019;&#x8868;&#x793A;<code>tasks.json</code>&#x6587;&#x4EF6;&#x7684;&#x7248;&#x672C;&#xFF0C;VSCode&#x4F7F;&#x7528;&#x9019;&#x500B;&#x7248;&#x672C;&#x4F86;&#x7406;&#x89E3;&#x6587;&#x4EF6;&#x683C;&#x5F0F;&#x3002;</li></ul>
<p><code>&quot;tasks&quot;</code>&#x4E2D;&#x7684;&#x6BCF;&#x500B;<code>key</code>:</p>
<ul><li><code>&quot;type&quot;: &quot;cppbuild&quot;</code>: &#x5B9A;&#x7FA9;&#x4E86;&#x4EFB;&#x52D9;&#x7684;&#x985E;&#x578B;&#xFF0C;<code>cppbuild</code>&#x662F;&#x7528;&#x4F86;&#x6A19;&#x793A;&#x9019;&#x662F;&#x4E00;&#x500B; C++&#x7DE8;&#x8B6F;&#x4EFB;&#x52D9;&#xFF0C;VSCode&#x6703;&#x91DD;&#x5C0D;&#x9019;&#x7A2E;&#x985E;&#x578B;&#x7684;&#x4EFB;&#x52D9;&#x63D0;&#x4F9B;&#x76F8;&#x61C9;&#x7684;&#x652F;&#x63F4;&#xFF0C;&#x4F8B;&#x5982; C++ &#x64F4;&#x5145;&#x5957;&#x4EF6;&#x6703;&#x76E3;&#x63A7;&#x9019;&#x7A2E;&#x7DE8;&#x8B6F;&#x904E;&#x7A0B;&#x3002;</li><li><code>&quot;label&quot;: &quot;C/C++: g++.exe &#x5EFA;&#x7F6E;&#x4F7F;&#x7528;&#x4E2D;&#x6A94;&#x6848;&quot;</code>: &#x4EFB;&#x52D9;&#x7684;&#x6A19;&#x7C64;&#xFF0C;&#x7528;&#x4F86;&#x63CF;&#x8FF0;&#x9019;&#x500B;&#x4EFB;&#x52D9;&#x7684;&#x7528;&#x9014;&#x53EF;&#x4EE5;&#x96A8;&#x610F;&#x547D;&#x540D;&#xFF0C;&#x6703;&#x5728;VSCode&#x7684;&#x4EFB;&#x52D9;&#x5217;&#x8868;&#x4E2D;&#x986F;&#x793A;&#x51FA;&#x4F86;&#xFF0C;&#x9019;&#x500B;&#x6A19;&#x7C64;&#x8868;&#x660E;&#x9019;&#x500B;&#x4EFB;&#x52D9;&#x662F;&#x4F7F;&#x7528;<code>g++.exe</code>&#x7DE8;&#x8B6F;&#x7576;&#x524D;&#x958B;&#x555F;&#x7684;C++&#x6A94;&#x6848;&#x3002;</li></ul>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/10/image-14.png" class="kg-image" alt="VS Code Note 02" loading="lazy" width="1436" height="201" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/10/image-14.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2024/10/image-14.png 1000w, https://ghost.augustushsu.com/content/images/2024/10/image-14.png 1436w" sizes="(min-width: 720px) 720px"></figure>
<ul><li><code>&quot;command&quot;: &quot;C:\\msys64\\ucrt64\\bin\\g++.exe&quot;</code>: &#x9019;&#x662F;&#x5BE6;&#x969B;&#x57F7;&#x884C;&#x7684;&#x547D;&#x4EE4;&#xFF0C;&#x9019;&#x88E1;&#x6307;&#x7684;&#x662F;MSYS2&#x7684;<code>g++</code>&#x7DE8;&#x8B6F;&#x5668;&#xFF0C;&#x5B83;&#x4F4D;&#x65BC;&#x6307;&#x5B9A;&#x7684;&#x8DEF;&#x5F91;&#x4E0B;(<code>C:\\msys64\\ucrt64\\bin\\g++.exe</code>)&#xFF0C;&#x9019;&#x500B;&#x547D;&#x4EE4;&#x6703;&#x88AB;&#x7528;&#x4F86;&#x7DE8;&#x8B6F; C++ &#x6A94;&#x6848;&#x3002;</li><li><code>&quot;args&quot;</code>: &#x5B9A;&#x7FA9;&#x4E86;&#x57F7;&#x884C;&#x7DE8;&#x8B6F;&#x5668;&#x6642;&#x8981;&#x50B3;&#x905E;&#x7684;&#x53C3;&#x6578;&#x3002;&#x6BCF;&#x500B;&#x53C3;&#x6578;&#x6703;&#x5728;&#x57F7;&#x884C;&#x547D;&#x4EE4;&#x6642;&#x4F9D;&#x6B21;&#x52A0;&#x5728;&#x5F8C;&#x9762;&#xFF1A;<ul><li><code>&quot;-fdiagnostics-color=always&quot;</code>: &#x7528;&#x4F86;&#x555F;&#x7528;&#x7DE8;&#x8B6F;&#x5668;&#x8F38;&#x51FA;&#x7684;&#x5F69;&#x8272;&#x8A3A;&#x65B7;&#x4FE1;&#x606F;&#xFF0C;&#x65B9;&#x4FBF;&#x8B58;&#x5225;&#x932F;&#x8AA4;&#x548C;&#x8B66;&#x544A;&#x3002;</li><li><code>&quot;-g&quot;</code>: &#x7528;&#x4F86;&#x544A;&#x8A34;&#x7DE8;&#x8B6F;&#x5668;&#x751F;&#x6210;&#x5305;&#x542B;&#x8ABF;&#x8A66;&#x8CC7;&#x8A0A;&#x7684;&#x53EF;&#x57F7;&#x884C;&#x6A94;&#x6848;&#xFF0C;&#x9019;&#x6A23;&#x53EF;&#x4EE5;&#x5728;&#x8ABF;&#x8A66;&#x968E;&#x6BB5;&#x66F4;&#x5BB9;&#x6613;&#x8FFD;&#x8E64;&#x7A0B;&#x5F0F;&#x884C;&#x70BA;&#x3002;</li><li><code>&quot;${file}&quot;</code>: &#x4EE3;&#x8868;&#x7576;&#x524D;&#x6253;&#x958B;&#x7684;&#x6A94;&#x6848;&#xFF0C;VSCode&#x6703;&#x81EA;&#x52D5;&#x5C07;&#x9019;&#x500B;&#x8B8A;&#x6578;&#x66FF;&#x63DB;&#x70BA;&#x5BE6;&#x969B;&#x6587;&#x4EF6;&#x7684;&#x8DEF;&#x5F91;&#xFF0C;&#x4E26;&#x5C07;&#x8A72;&#x6587;&#x4EF6;&#x4F5C;&#x70BA;&#x7DE8;&#x8B6F;&#x7684;&#x8F38;&#x5165;&#x3002;</li><li><code>&quot;${fileDirname}\\${fileBasenameNoExtension}.exe&quot;</code>: &#x9019;&#x500B;&#x53C3;&#x6578;&#x6307;&#x5B9A;&#x4E86;&#x8F38;&#x51FA;&#x7684;&#x53EF;&#x57F7;&#x884C;&#x6587;&#x4EF6;&#x7684;&#x540D;&#x7A31;&#x3002;<code>&quot;${fileDirname}&quot;</code>&#x662F;&#x7576;&#x524D;&#x6A94;&#x6848;&#x6240;&#x5728;&#x7684;&#x76EE;&#x9304;&#xFF0C;<code>&quot;${fileBasenameNoExtension}&quot;</code>&#x662F;&#x4E0D;&#x5E36;&#x526F;&#x6A94;&#x540D;&#x7684;&#x6587;&#x4EF6;&#x540D;&#x7A31;&#xFF0C;&#x6700;&#x5F8C;&#x7DE8;&#x8B6F;&#x751F;&#x6210;&#x7684;&#x53EF;&#x57F7;&#x884C;&#x6A94;&#x6848;&#x662F;<code>.exe</code>&#x3002;</li></ul></li><li><code>&quot;options&quot;</code>: &#x5B9A;&#x7FA9;&#x4E86;&#x57F7;&#x884C;&#x7DE8;&#x8B6F;&#x547D;&#x4EE4;&#x7684;&#x9078;&#x9805;&#xFF0C;&#x9019;&#x88E1;&#x7684;<code>cwd</code> (current working directory) &#x8A2D;&#x7F6E;&#x70BA;<code>${fileDirname}</code>&#xFF0C;&#x5373;&#x7576;&#x524D;&#x6253;&#x958B;&#x6A94;&#x6848;&#x7684;&#x76EE;&#x9304;&#x3002;&#x9019;&#x78BA;&#x4FDD;&#x7DE8;&#x8B6F;&#x547D;&#x4EE4;&#x5728;&#x8A72;&#x6A94;&#x6848;&#x6240;&#x5728;&#x7684;&#x76EE;&#x9304;&#x4E2D;&#x57F7;&#x884C;&#x3002;</li><li><code>&quot;problemMatcher&quot;</code>: &#x5B9A;&#x7FA9;&#x4E86;&#x554F;&#x984C;&#x5339;&#x914D;&#x5668;&#xFF0C;&#x7528;&#x4F86;&#x8B58;&#x5225;&#x7DE8;&#x8B6F;&#x5668;&#x8F38;&#x51FA;&#x7684;&#x932F;&#x8AA4;&#x548C;&#x8B66;&#x544A;&#xFF0C;<code>&quot;$gcc&quot;</code>&#x662F;&#x4E00;&#x500B;&#x5167;&#x5EFA;&#x7684;&#x554F;&#x984C;&#x5339;&#x914D;&#x5668;&#xFF0C;&#x9069;&#x7528;&#x65BC;GCC&#x7DE8;&#x8B6F;&#x5668; (&#x5305;&#x62EC; <code>g++</code>)&#x3002;&#x5B83;&#x6703;&#x89E3;&#x6790;&#x7DE8;&#x8B6F;&#x5668;&#x7684;&#x8F38;&#x51FA;&#x4E26;&#x986F;&#x793A;&#x5728;VSCode&#x554F;&#x984C;&#x9762;&#x677F;&#x4E2D;&#xFF0C;&#x8B93;&#x958B;&#x767C;&#x8005;&#x80FD;&#x65B9;&#x4FBF;&#x5730;&#x67E5;&#x770B;&#x932F;&#x8AA4;&#x4F4D;&#x7F6E;&#x3002;</li><li><code>&quot;group&quot;</code>: &#x9019;&#x500B;&#x9375;&#x5B9A;&#x7FA9;&#x4E86;&#x4EFB;&#x52D9;&#x5206;&#x7D44;&#x7684;&#x5C6C;&#x6027;&#xFF1A;<ul><li><code>&quot;kind&quot;: &quot;build&quot;</code>: &#x9019;&#x8868;&#x793A;&#x9019;&#x500B;&#x4EFB;&#x52D9;&#x5C6C;&#x65BC;&#x300C;&#x7DE8;&#x8B6F;&#x300D;&#x985E;&#x5225;&#xFF0C;VSCode &#x6703;&#x5C07;&#x5176;&#x5206;&#x985E;&#x5230;&#x7DE8;&#x8B6F;&#x4EFB;&#x52D9;&#x3002;</li><li><code>&quot;isDefault&quot;: true</code>: &#x9019;&#x8868;&#x793A;&#x9019;&#x500B;&#x4EFB;&#x52D9;&#x662F;&#x9ED8;&#x8A8D;&#x7684;&#x7DE8;&#x8B6F;&#x4EFB;&#x52D9;&#xFF0C;&#x7576;&#x4F7F;&#x7528;&#x5FEB;&#x6377;&#x9375; (&#x5982; <code>Ctrl+Shift+B</code>) &#x555F;&#x52D5;&#x7DE8;&#x8B6F;&#x6642;&#xFF0C;VSCode&#x6703;&#x57F7;&#x884C;&#x9019;&#x500B;&#x4EFB;&#x52D9;&#x3002;</li></ul></li><li><code>&quot;detail&quot;: &quot;&#x5075;&#x932F;&#x5DE5;&#x5177;&#x7522;&#x751F;&#x7684;&#x5DE5;&#x4F5C;&#x3002;&quot;</code>: &#x9019;&#x662F;&#x4EFB;&#x52D9;&#x7684;&#x8A73;&#x7D30;&#x63CF;&#x8FF0;&#xFF0C;&#x7528;&#x4F86;&#x5E6B;&#x52A9;&#x958B;&#x767C;&#x8005;&#x4E86;&#x89E3;&#x4EFB;&#x52D9;&#x7684;&#x7528;&#x9014;&#x3002;</li></ul>
<p>&#x5982;&#x679C;&#x5EFA;&#x7F6E;&#x7684;&#x6642;&#x5019;&#x9700;&#x8981;&#x4F7F;&#x7528;&#x591A;&#x500B;cpp&#x6A94;&#x6848;&#x4F86;&#x5EFA;&#x7F6E;&#xFF0C;&#x53EF;&#x4EE5;&#x4FEE;&#x6539;<code>tasks.json</code>&#x6A94;&#x6848;&#x7684;<code>args</code>&#xFF0C;&#x5C07;<code>&quot;${file}&quot;</code>&#x6539;&#x70BA;<code>&quot;${workspaceFolder}/*.cpp&quot;</code>&#xFF0C;&#x5C07;&#x5EFA;&#x7F6E;&#x7576;&#x524D;&#x8CC7;&#x6599;&#x593E;&#x6240;&#x6709;&#x7684;cpp&#x6A94;&#x6848;&#xFF1B;&#x539F;&#x672C;<code>&quot;${fileDirname}\\${fileBasenameNoExtension}.exe&quot;</code>&#x662F;&#x6703;&#x6839;&#x64DA;&#x7576;&#x524D;&#x958B;&#x59CB;&#x7684;&#x6A94;&#x6848;&#x751F;&#x6210;&#x4E00;&#x500B;&#x8207;&#x8A72;&#x6A94;&#x6848;&#x540D;&#x7A31;&#x76F8;&#x540C;&#x7684;exe&#x6A94;&#xFF0C;&#x6539;&#x70BA;<code>&quot;${workspaceFolder}\\myProgram.exe&quot;</code>&#x4EE3;&#x8868;&#x5C07;&#x6240;&#x6709;cpp&#x6A94;&#x90FD;&#x5C07;&#x7DE8;&#x8B6F;&#x4E26;&#x93C8;&#x63A5;&#x6210;&#x4E00;&#x500B;&#x540D;&#x70BA;<code>myProgram.exe</code>&#x7684;&#x6A94;&#x6848;&#xFF0C;&#x9019;&#x9069;&#x5408;&#x5C08;&#x6848;&#x4E2D;&#x6709;&#x591A;&#x500B;&#x6E90;&#x6587;&#x4EF6;&#xFF0C;&#x4F46;&#x6700;&#x7D42;&#x53EA;&#x751F;&#x6210;&#x4E00;&#x500B;&#x53EF;&#x57F7;&#x884C;&#x6A94;&#x6848;&#x7684;&#x60C5;&#x6CC1;&#x3002;</p>
<h2 id="launchjson">launch.json</h2>
<p><code>launch.json</code>&#x7528;&#x65BC;&#x8A2D;&#x5B9A;VSCode&#x8ABF;&#x8A66;C++&#x7A0B;&#x5F0F;&#x7684;&#x914D;&#x7F6E;&#xFF0C;&#x5728;&#x7DE8;&#x8F2F;C++&#x7A0B;&#x5F0F;&#x5F8C;&#x9700;&#x8981;&#x555F;&#x52D5;&#x8ABF;&#x8A66;&#x5668;&#x6642;&#xFF0C;VSCode&#x6703;&#x6839;&#x64DA;&#x9019;&#x500B;&#x6587;&#x4EF6;&#x4E2D;&#x7684;&#x914D;&#x7F6E;&#x4F86;&#x57F7;&#x884C;&#x8ABF;&#x8A66;&#x904E;&#x7A0B;&#x3002;&#x904E;&#x7A0B;&#x5305;&#x62EC;&#x6307;&#x5B9A;&#x8981;&#x8ABF;&#x8A66;&#x7684;&#x53EF;&#x57F7;&#x884C;&#x6587;&#x4EF6;&#x3001;&#x8A2D;&#x5B9A;&#x8ABF;&#x8A66;&#x5668; (&#x9019;&#x88E1;&#x4F7F;&#x7528;GDB)&#x3001;&#x5728;&#x8ABF;&#x8A66;&#x904E;&#x7A0B;&#x4E2D;&#x5982;&#x4F55;&#x8655;&#x7406;&#x547D;&#x4EE4;&#x5217;&#x53C3;&#x6578;&#x3001;&#x5DE5;&#x4F5C;&#x76EE;&#x9304;&#x3001;&#x74B0;&#x5883;&#x8B8A;&#x6578;&#x7B49;&#x3001;&#x8A2D;&#x5B9A;&#x8ABF;&#x8A66;&#x524D;&#x662F;&#x5426;&#x9700;&#x8981;&#x57F7;&#x884C;&#x7DE8;&#x8B6F;&#x4EFB;&#x52D9;&#x3002;</p>
<p><code>launch.json</code>&#x7684;&#x7BC4;&#x4F8B;:</p>
<pre><code class="language-json">{
    &quot;configurations&quot;: [
        {
            &quot;name&quot;: &quot;C/C++: g++.exe &#x5EFA;&#x7F6E;&#x53CA;&#x5075;&#x932F;&#x4F7F;&#x7528;&#x4E2D;&#x7684;&#x6A94;&#x6848;&quot;,
            &quot;type&quot;: &quot;cppdbg&quot;,
            &quot;request&quot;: &quot;launch&quot;,
            &quot;program&quot;: &quot;${fileDirname}\\${fileBasenameNoExtension}.exe&quot;,
            &quot;args&quot;: [],
            &quot;stopAtEntry&quot;: false,
            &quot;cwd&quot;: &quot;${fileDirname}&quot;,
            &quot;environment&quot;: [],
            &quot;externalConsole&quot;: false,
            &quot;MIMode&quot;: &quot;gdb&quot;,
            &quot;miDebuggerPath&quot;: &quot;C:\\msys64\\ucrt64\\bin\\gdb.exe&quot;,
            &quot;setupCommands&quot;: [
                {
                    &quot;description&quot;: &quot;&#x555F;&#x7528; gdb &#x7684;&#x7F8E;&#x5316;&#x986F;&#x793A;&quot;,
                    &quot;text&quot;: &quot;-enable-pretty-printing&quot;,
                    &quot;ignoreFailures&quot;: true
                },
                {
                    &quot;description&quot;: &quot;&#x5C07;&#x53CD;&#x7D44;&#x8B6F;&#x78BC;&#x8B8A;&#x9AD4;&#x8A2D;&#x70BA; Intel&quot;,
                    &quot;text&quot;: &quot;-gdb-set disassembly-flavor intel&quot;,
                    &quot;ignoreFailures&quot;: true
                }
            ],
            &quot;preLaunchTask&quot;: &quot;C/C++: g++.exe &#x5EFA;&#x7F6E;&#x4F7F;&#x7528;&#x4E2D;&#x6A94;&#x6848;&quot;
        }
    ],
    &quot;version&quot;: &quot;2.0.0&quot;
}</code></pre>
<p>&#x9019;&#x662F;&#x4E00;&#x500B;&#x555F;&#x52D5;&#x8ABF;&#x8A66;&#x904E;&#x7A0B;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#xFF0C;<code>&quot;configurations&quot;</code>&#x5167;&#x5404;&#x500B;&#x53C3;&#x6578;&#x7684;&#x5B9A;&#x7FA9;&#x5982;&#x4E0B;:</p>
<ul><li><code>&quot;name&quot;</code>: &#x9019;&#x662F;&#x8ABF;&#x8A66;&#x914D;&#x7F6E;&#x7684;&#x540D;&#x7A31;&#xFF0C;&#x7528;&#x4F86;&#x6A19;&#x8B58;&#x9019;&#x500B;&#x8ABF;&#x8A66;&#x4EFB;&#x52D9;&#xFF0C;&#x53EF;&#x4EE5;&#x96A8;&#x610F;&#x547D;&#x540D;&#xFF0C;&#x6703;&#x5728;VSCode&#x8ABF;&#x8A66;&#x9762;&#x677F;&#x4E2D;&#x986F;&#x793A;&#x51FA;&#x4F86;&#xFF0C;&#x9019;&#x500B;&#x540D;&#x7A31;&#x8868;&#x660E;&#x8A72;&#x914D;&#x7F6E;&#x662F;&#x7528;&#x4F86;&#x7DE8;&#x8B6F;&#x4E26;&#x8ABF;&#x8A66;&#x7576;&#x524D;&#x6253;&#x958B;&#x7684; C++ &#x6A94;&#x6848;&#x3002;</li><li><code>&quot;type&quot;: &quot;cppdbg&quot;</code>: &#x5B9A;&#x7FA9;&#x4E86;&#x8ABF;&#x8A66;&#x7684;&#x985E;&#x578B;&#xFF0C;<code>cppdbg</code>&#x662F;&#x7528;&#x4F86;&#x8868;&#x793A;&#x9019;&#x662F;&#x4E00;&#x500B; C++ &#x8ABF;&#x8A66;&#x4EFB;&#x52D9;&#xFF0C;VSCode &#x6703;&#x4F7F;&#x7528;&#x9019;&#x500B;&#x985E;&#x578B;&#x4F86;&#x555F;&#x52D5;&#x5C0D;&#x61C9;&#x7684; C++ &#x8ABF;&#x8A66;&#x529F;&#x80FD;&#xFF0C;&#x901A;&#x5E38;&#x8207; GDB &#x6216; LLDB &#x8ABF;&#x8A66;&#x5668;&#x7D50;&#x5408;&#x4F7F;&#x7528;&#x3002;</li><li><code>&quot;request&quot;: &quot;launch&quot;</code>: &#x5B9A;&#x7FA9;&#x8ABF;&#x8A66;&#x8ACB;&#x6C42;&#x7684;&#x985E;&#x578B;&#xFF0C;<code>launch</code>&#x8868;&#x793A;&#x6703;&#x555F;&#x52D5;&#x4E00;&#x500B;&#x65B0;&#x7684;&#x53EF;&#x57F7;&#x884C;&#x6587;&#x4EF6;&#x4E26;&#x9032;&#x884C;&#x8ABF;&#x8A66;&#xFF0C;&#x5982;&#x679C;&#x662F;<code>attach</code>&#xFF0C;&#x5247;&#x8868;&#x793A;&#x6703;&#x9644;&#x52A0;&#x5230;&#x5DF2;&#x7D93;&#x904B;&#x884C;&#x7684;&#x7A0B;&#x5E8F;&#x4E0A;&#x9032;&#x884C;&#x8ABF;&#x8A66;&#x3002;</li><li><code>&quot;program&quot;: &quot;${fileDirname}\${fileBasenameNoExtension}.exe&quot;</code>: &#x6307;&#x5B9A;&#x8981;&#x8ABF;&#x8A66;&#x7684;&#x53EF;&#x57F7;&#x884C;&#x6587;&#x4EF6;&#x7684;&#x8DEF;&#x5F91;&#xFF0C;<code>${fileDirname}</code> &#x4EE3;&#x8868;&#x7576;&#x524D;&#x6A94;&#x6848;&#x6240;&#x5728;&#x7684;&#x76EE;&#x9304;&#xFF0C;<code>${fileBasenameNoExtension}</code> &#x662F;&#x7576;&#x524D;&#x6253;&#x958B;&#x6A94;&#x6848;&#x4E0D;&#x5E36;&#x526F;&#x6A94;&#x540D;&#x7684;&#x6587;&#x4EF6;&#x540D;&#x7A31;&#xFF0C;&#x9019;&#x6A23;&#x53EF;&#x4EE5;&#x751F;&#x6210; <code>.exe</code> &#x6A94;&#x6848;&#x4F5C;&#x70BA;&#x8ABF;&#x8A66;&#x76EE;&#x6A19;&#x3002;</li><li><code>&quot;args&quot;: []</code>: &#x5B9A;&#x7FA9;&#x4E86;&#x5728;&#x8ABF;&#x8A66;&#x904E;&#x7A0B;&#x4E2D;&#x50B3;&#x905E;&#x7D66;&#x53EF;&#x57F7;&#x884C;&#x6587;&#x4EF6;&#x7684;&#x547D;&#x4EE4;&#x5217;&#x53C3;&#x6578;&#xFF0C;&#x5982;&#x679C;&#x9700;&#x8981;&#x5728;&#x555F;&#x52D5;&#x6642;&#x50B3;&#x905E;&#x7279;&#x5B9A;&#x53C3;&#x6578;&#xFF0C;&#x53EF;&#x4EE5;&#x5728;&#x6B64;&#x8A2D;&#x5B9A;&#x3002;</li><li><code>&quot;stopAtEntry&quot;: false</code>: &#x5B9A;&#x7FA9;&#x662F;&#x5426;&#x5728;&#x7A0B;&#x5E8F;&#x9032;&#x5165;&#x5165;&#x53E3;&#x9EDE;&#x6642; (&#x901A;&#x5E38;&#x662F; <code>main</code> &#x51FD;&#x6578;) &#x81EA;&#x52D5;&#x505C;&#x6B62;&#x8ABF;&#x8A66;&#x3002;&#x5982;&#x679C;&#x8A2D;&#x70BA; <code>true</code>&#xFF0C;&#x7A0B;&#x5E8F;&#x6703;&#x5728;&#x5165;&#x53E3;&#x9EDE;&#x8655;&#x66AB;&#x505C;&#xFF0C;&#x65B9;&#x4FBF;&#x958B;&#x767C;&#x8005;&#x6AA2;&#x67E5;&#x521D;&#x59CB;&#x72C0;&#x614B;&#x3002;&#x8A2D;&#x70BA; <code>false</code> &#x8868;&#x793A;&#x7A0B;&#x5E8F;&#x5C07;&#x6703;&#x76F4;&#x63A5;&#x57F7;&#x884C;&#xFF0C;&#x76F4;&#x5230;&#x9047;&#x5230;&#x65B7;&#x9EDE;&#x6216;&#x7D50;&#x675F;&#x3002;</li><li><code>&quot;cwd&quot;: &quot;${fileDirname}&quot;</code>: &#x6307;&#x5B9A;&#x8ABF;&#x8A66;&#x904E;&#x7A0B;&#x4E2D;&#x57F7;&#x884C;&#x7A0B;&#x5E8F;&#x7684;&#x7576;&#x524D;&#x5DE5;&#x4F5C;&#x76EE;&#x9304;&#xFF0C;<code>${fileDirname}</code> &#x4EE3;&#x8868;&#x7576;&#x524D;&#x6253;&#x958B;&#x6A94;&#x6848;&#x6240;&#x5728;&#x7684;&#x76EE;&#x9304;&#xFF0C;&#x78BA;&#x4FDD;&#x7A0B;&#x5E8F;&#x5728;&#x9019;&#x500B;&#x76EE;&#x9304;&#x4E2D;&#x57F7;&#x884C;&#x3002;</li><li><code>&quot;environment&quot;: []</code>: &#x5B9A;&#x7FA9;&#x4E86;&#x8ABF;&#x8A66;&#x904E;&#x7A0B;&#x4E2D;&#x8981;&#x8A2D;&#x7F6E;&#x7684;&#x74B0;&#x5883;&#x8B8A;&#x6578;&#xFF0C;&#x7576;&#x524D;&#x662F;&#x7A7A;&#x5217;&#x8868;&#xFF0C;&#x8868;&#x793A;&#x4E0D;&#x6703;&#x8A2D;&#x7F6E;&#x4EFB;&#x4F55;&#x984D;&#x5916;&#x7684;&#x74B0;&#x5883;&#x8B8A;&#x6578;&#x3002;&#x5982;&#x679C;&#x9700;&#x8981;&#x70BA;&#x7A0B;&#x5E8F;&#x904B;&#x884C;&#x8A2D;&#x7F6E;&#x7279;&#x5B9A;&#x7684;&#x74B0;&#x5883;&#x8B8A;&#x6578;&#xFF0C;&#x53EF;&#x4EE5;&#x5728;&#x6B64;&#x6DFB;&#x52A0;&#x3002;</li><li><code>&quot;MIMode&quot;: &quot;gdb&quot;</code>: &#x6307;&#x5B9A;&#x4F7F;&#x7528;&#x54EA;&#x7A2E;&#x8ABF;&#x8A66;&#x5354;&#x8B70;&#x3002;<code>gdb</code>&#x8868;&#x793A;&#x4F7F;&#x7528;GNU Debugger (GDB) &#x4F86;&#x9032;&#x884C;&#x8ABF;&#x8A66;&#x3002;&#x5982;&#x679C;&#x4F7F;&#x7528;&#x7684;&#x662F;LLDB&#x8ABF;&#x8A66;&#x5668;&#xFF0C;&#x9019;&#x88E1;&#x53EF;&#x4EE5;&#x8A2D;&#x70BA;<code>lldb</code>&#x3002;</li><li><code>&quot;miDebuggerPath&quot;: &quot;C:\msys64\ucrt64\bin\gdb.exe&quot;</code>: &#x5B9A;&#x7FA9;&#x4E86;GDB&#x8ABF;&#x8A66;&#x5668;&#x7684;&#x8DEF;&#x5F91;&#x3002;&#x9019;&#x88E1;&#x6307;&#x5B9A;&#x4E86;MSYS2&#x5B89;&#x88DD;&#x7684;GDB&#x8ABF;&#x8A66;&#x5668;&#x6240;&#x5728;&#x7684;&#x8DEF;&#x5F91;&#xFF0C;&#x8B93;VSCode&#x77E5;&#x9053;&#x5728;&#x54EA;&#x88E1;&#x627E;&#x5230;&#x8ABF;&#x8A66;&#x5668;&#x9032;&#x884C;&#x8ABF;&#x8A66;&#x3002;</li><li><strong><code>&quot;setupCommands&quot;</code></strong>: &#x5B9A;&#x7FA9;&#x4E86;&#x4E00;&#x4E9B;&#x5728;&#x8ABF;&#x8A66;&#x904E;&#x7A0B;&#x4E2D;&#x57F7;&#x884C;&#x7684;&#x521D;&#x59CB;&#x547D;&#x4EE4;&#xFF0C;&#x9019;&#x4E9B;&#x547D;&#x4EE4;&#x901A;&#x5E38;&#x7528;&#x4F86;&#x914D;&#x7F6E;&#x8ABF;&#x8A66;&#x5668;&#x7684;&#x884C;&#x70BA;&#x3002;<ul><li><code>{ &quot;description&quot;: &quot;&#x555F;&#x7528; gdb &#x7684;&#x7F8E;&#x5316;&#x986F;&#x793A;&quot;, &quot;text&quot;: &quot;-enable-pretty-printing&quot;, &quot;ignoreFailures&quot;: true }</code>:<br>&#x9019;&#x500B;&#x547D;&#x4EE4;&#x7528;&#x4F86;&#x555F;&#x7528;GDB&#x7684;&#x7F8E;&#x5316;&#x986F;&#x793A;&#x529F;&#x80FD; (pretty printing)&#xFF0C;&#x9019;&#x6A23;&#x53EF;&#x4EE5;&#x66F4;&#x597D;&#x5730;&#x683C;&#x5F0F;&#x5316;&#x986F;&#x793A;STL&#x5BB9;&#x5668;&#x7B49;&#x8907;&#x96DC;&#x7684;&#x6578;&#x64DA;&#x7D50;&#x69CB;&#xFF0C;&#x4F7F;&#x5176;&#x66F4;&#x6613;&#x65BC;&#x95B1;&#x8B80;&#x548C;&#x8ABF;&#x8A66;&#x3002;</li><li><code>{ &quot;description&quot;: &quot;&#x5C07;&#x53CD;&#x7D44;&#x8B6F;&#x78BC;&#x8B8A;&#x9AD4;&#x8A2D;&#x70BA; Intel&quot;, &quot;text&quot;: &quot;-gdb-set disassembly-flavor intel&quot;, &quot;ignoreFailures&quot;: true }</code>:<br>&#x9019;&#x500B;&#x547D;&#x4EE4;&#x8A2D;&#x7F6E;GDB&#x4F7F;&#x7528;Intel&#x8A9E;&#x6CD5;&#x9032;&#x884C;&#x53CD;&#x7D44;&#x8B6F;&#x986F;&#x793A;&#xFF0C;&#x9019;&#x5C0D;&#x65BC;&#x7FD2;&#x6163;Intel&#x6307;&#x4EE4;&#x96C6;&#x7684;&#x958B;&#x767C;&#x8005;&#x4F86;&#x8AAA;&#x6703;&#x66F4;&#x5BB9;&#x6613;&#x95B1;&#x8B80;&#x3002;</li></ul></li><li><code>&quot;preLaunchTask&quot;: &quot;C/C++: g++.exe &#x5EFA;&#x7F6E;&#x4F7F;&#x7528;&#x4E2D;&#x6A94;&#x6848;&quot;</code>: &#x6307;&#x5B9A;&#x5728;&#x555F;&#x52D5;&#x8ABF;&#x8A66;&#x4E4B;&#x524D;&#x9700;&#x8981;&#x57F7;&#x884C;&#x7684;&#x4EFB;&#x52D9;&#x3002;&#x5728;&#x6B64;&#x60C5;&#x6CC1;&#x4E0B;&#xFF0C;<code>&quot;C/C++: g++.exe &#x5EFA;&#x7F6E;&#x4F7F;&#x7528;&#x4E2D;&#x6A94;&#x6848;&quot;</code> &#x662F;&#x5728;<code>tasks.json</code>&#x4E2D;&#x5B9A;&#x7FA9;&#x7684;&#x7DE8;&#x8B6F;&#x4EFB;&#x52D9;&#xFF0C;&#x9019;&#x78BA;&#x4FDD;&#x5728;&#x6BCF;&#x6B21;&#x555F;&#x52D5;&#x8ABF;&#x8A66;&#x4E4B;&#x524D;&#x6703;&#x91CD;&#x65B0;&#x7DE8;&#x8B6F;&#x6700;&#x65B0;&#x7248;&#x672C;&#x7684;&#x7A0B;&#x5F0F;&#x78BC;&#x3002;</li></ul>
<h2 id="cmake">CMake</h2>
<p>Windows&#x53EF;&#x4EE5;&#x53BB;<a href="https://cmake.org/download/?ref=ghost.augustushsu.com">CMake&#x7684;&#x7DB2;&#x7AD9;</a>&#x627E;&#x5230;&#x5C0D;&#x61C9;&#x4F5C;&#x696D;&#x7CFB;&#x7D71;&#x7684;&#x7248;&#x672C;&#x4E0B;&#x8F09;&#x5B89;&#x88DD;&#xFF0C;Ubuntu&#x53EF;&#x4EE5;&#x900F;&#x904E;<code>sudo apt-get install cmake</code>&#x4F86;&#x5B89;&#x88DD;&#xFF0C;&#x5982;&#x679C;&#x662F;Windows&#x7CFB;&#x7D71;&#x53EF;&#x4EE5;&#x5728;&#x5B89;&#x88DD;&#x904E;&#x7A0B;&#x4E2D;&#x9EDE;&#x9078;<code>Add CMake to the PATH environment variable</code>&#x9019;&#x6A23;&#x53EF;&#x4EE5;&#x5728;terminal&#x4E0A;&#x76F4;&#x63A5;&#x4F7F;&#x7528;CMake:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/10/image-15.png" class="kg-image" alt="VS Code Note 02" loading="lazy" width="487" height="378"></figure>
<p>&#x5B89;&#x88DD;&#x5B8C;&#x6210;&#x5F8C;&#xFF0C;&#x5728;terminal&#x4E0A;&#x8F38;&#x5165;<code>cmake --version</code>&#x78BA;&#x8A8D;&#x662F;&#x5426;&#x5B89;&#x88DD;&#x6210;&#x529F;&#x3002;</p>
<p>&#x53EF;&#x4EE5;&#x900F;&#x904E;VSCode&#x7684;&#x547D;&#x4EE4;&#x9762;&#x677F; (<code>Ctrl+Shift+P</code>) &#x57F7;&#x884C;CMake: Quick Start:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/10/image-16.png" class="kg-image" alt="VS Code Note 02" loading="lazy" width="723" height="101" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/10/image-16.png 600w, https://ghost.augustushsu.com/content/images/2024/10/image-16.png 723w" sizes="(min-width: 720px) 720px"></figure>
<p>&#x8F38;&#x5165;&#x5C08;&#x6848;&#x540D;&#x7A31;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/10/image-17.png" class="kg-image" alt="VS Code Note 02" loading="lazy" width="715" height="77" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/10/image-17.png 600w, https://ghost.augustushsu.com/content/images/2024/10/image-17.png 715w"></figure>
<p>&#x9078;&#x64C7;C++&#x4F5C;&#x70BA;&#x5C08;&#x6848;&#x8A9E;&#x8A00;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/10/image-18.png" class="kg-image" alt="VS Code Note 02" loading="lazy" width="717" height="100" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/10/image-18.png 600w, https://ghost.augustushsu.com/content/images/2024/10/image-18.png 717w"></figure>
<p>&#x9078;&#x64C7;&#x5EFA;&#x7ACB;&#x53EF;&#x57F7;&#x884C;&#x6A94;&#xFF0C;&#x5982;&#x679C;&#x662F;&#x60F3;&#x5EFA;&#x7ACB;&#x7A0B;&#x5F0F;&#x5EAB;&#x5247;&#x9078;&#x64C7;&#x4E0A;&#x65B9;&#x90A3;&#x500B;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/10/image-19.png" class="kg-image" alt="VS Code Note 02" loading="lazy" width="718" height="100" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/10/image-19.png 600w, https://ghost.augustushsu.com/content/images/2024/10/image-19.png 718w"></figure>
<p><strong><code>CPack</code></strong> &#x662F;&#x4E00;&#x500B;&#x6253;&#x5305;&#x5DE5;&#x5177;&#xFF0C;&#x7528;&#x4F86;&#x751F;&#x6210;&#x8EDF;&#x9AD4;&#x7684;&#x5B89;&#x88DD;&#x5305; (installers) &#x6216;&#x767C;&#x884C;&#x5305; (distribution packages)&#xFF1B;<strong><code>CTest</code></strong> &#x662F;&#x4E00;&#x500B;&#x6E2C;&#x8A66;&#x5DE5;&#x5177;&#xFF0C;&#x7528;&#x4F86;&#x904B;&#x884C;&#x548C;&#x7BA1;&#x7406;&#x5C08;&#x6848;&#x4E2D;&#x7684;&#x55AE;&#x5143;&#x6E2C;&#x8A66;&#x3001;&#x6574;&#x5408;&#x6E2C;&#x8A66;&#x7B49;&#xFF0C;&#x5E6B;&#x52A9;&#x9A57;&#x8B49;&#x5C08;&#x6848;&#x7684;&#x6B63;&#x78BA;&#x6027;&#x3002;&#x6839;&#x64DA;&#x9700;&#x6C42;&#x9078;&#x64C7;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/10/image-21.png" class="kg-image" alt="VS Code Note 02" loading="lazy" width="717" height="98" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/10/image-21.png 600w, https://ghost.augustushsu.com/content/images/2024/10/image-21.png 717w"></figure>
<p>&#x63A5;&#x4E0B;&#x4F86;&#x662F;&#x8981;&#x9078;&#x64C7;&#x9810;&#x8A2D;&#x7684;&#x7DE8;&#x8B6F;&#x5668;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/10/image-22.png" class="kg-image" alt="VS Code Note 02" loading="lazy" width="719" height="77" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/10/image-22.png 600w, https://ghost.augustushsu.com/content/images/2024/10/image-22.png 719w"></figure>
<p>&#x9078;&#x64C7;&#x5F9E;&#x7DE8;&#x8B6F;&#x5668;&#x5EFA;&#x7ACB;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/10/image-23.png" class="kg-image" alt="VS Code Note 02" loading="lazy" width="704" height="123" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/10/image-23.png 600w, https://ghost.augustushsu.com/content/images/2024/10/image-23.png 704w"></figure>
<p>&#x9019;&#x88E1;&#x9078;&#x64C7;&#x8981;&#x4F7F;&#x7528;&#x7684;&#x7DE8;&#x8B6F;&#x5668;&#x5373;&#x53EF;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/10/image-28.png" class="kg-image" alt="VS Code Note 02" loading="lazy" width="711" height="196" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/10/image-28.png 600w, https://ghost.augustushsu.com/content/images/2024/10/image-28.png 711w"></figure>
<p>&#x76F4;&#x63A5;&#x6309;Enter&#x6703;&#x4F7F;&#x7528;&#x9810;&#x8A2D;&#x7684;&#x540D;&#x7A31;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/10/image-26.png" class="kg-image" alt="VS Code Note 02" loading="lazy" width="714" height="73" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/10/image-26.png 600w, https://ghost.augustushsu.com/content/images/2024/10/image-26.png 714w"></figure>
<p>&#x5168;&#x90FD;&#x8A2D;&#x5B9A;&#x597D;&#x5F8C;&#x6703;&#x81EA;&#x52D5;&#x7522;&#x751F;<code>CMakePresets.json</code>&#x6A94;&#x6848;&#xFF0C;<code>CMakePresets.json</code>&#x662F;&#x4E00;&#x500B;&#x7528;&#x4F86;&#x7C21;&#x5316;CMake&#x914D;&#x7F6E;&#x3001;&#x69CB;&#x5EFA;&#x548C;&#x6E2C;&#x8A66;&#x904E;&#x7A0B;&#x7684;&#x6587;&#x4EF6;&#xFF0C;&#x5141;&#x8A31;&#x5728;&#x5C08;&#x6848;&#x4E2D;&#x5B9A;&#x7FA9;&#x591A;&#x500B;&#x4E0D;&#x540C;&#x7684;&#x9810;&#x8A2D;&#x914D;&#x7F6E;&#xFF0C;&#x4E26;&#x80FD;&#x5920;&#x8F15;&#x9B06;&#x5207;&#x63DB;&#x9019;&#x4E9B;&#x914D;&#x7F6E;&#xFF0C;&#x7D71;&#x4E00;&#x5728;&#x4E0D;&#x540C;&#x5E73;&#x53F0;&#x4E0A;&#x7684;&#x914D;&#x7F6E;&#x904E;&#x7A0B;&#xFF0C;&#x4E26;&#x63D0;&#x9AD8;&#x914D;&#x7F6E;&#x548C;&#x69CB;&#x5EFA;&#x7684;&#x6548;&#x7387;:</p>
<pre><code class="language-json">{
    &quot;version&quot;: 8,
    &quot;configurePresets&quot;: [
        {
            &quot;name&quot;: &quot;Visual Studio Build Tools 2022 Release - amd64&quot;,
            &quot;displayName&quot;: &quot;Visual Studio Build Tools 2022 Release - amd64&quot;,
            &quot;description&quot;: &quot;&#x4F7F;&#x7528; Visual Studio 17 2022 &#x7684;&#x7DE8;&#x8B6F;&#x5668;(x64 &#x67B6;&#x69CB;)&quot;,
            &quot;generator&quot;: &quot;Visual Studio 17 2022&quot;,
            &quot;toolset&quot;: &quot;host=x64&quot;,
            &quot;architecture&quot;: &quot;x64&quot;,
            &quot;binaryDir&quot;: &quot;${sourceDir}/out/build/${presetName}&quot;,
            &quot;cacheVariables&quot;: {
                &quot;CMAKE_INSTALL_PREFIX&quot;: &quot;${sourceDir}/out/install/${presetName}&quot;,
                &quot;CMAKE_C_COMPILER&quot;: &quot;cl.exe&quot;,
                &quot;CMAKE_CXX_COMPILER&quot;: &quot;cl.exe&quot;
            }
        }
    ],
    &quot;buildPresets&quot;: [
        {
            &quot;name&quot;: &quot;Visual Studio Build Tools 2022 Release - amd64-debug&quot;,
            &quot;displayName&quot;: &quot;Visual Studio Build Tools 2022 Release - amd64 - Debug&quot;,
            &quot;configurePreset&quot;: &quot;Visual Studio Build Tools 2022 Release - amd64&quot;,
            &quot;configuration&quot;: &quot;Debug&quot;
        }
    ]
}</code></pre>
<p>&#x63A5;&#x4E0B;&#x4F86;&#x4F7F;&#x7528;<code>CMake: Configure</code>&#x4F86;&#x914D;&#x7F6E;&#x5C08;&#x6848;&#xFF0C;&#x751F;&#x6210;&#x69CB;&#x5EFA;&#x7CFB;&#x7D71;&#x6587;&#x4EF6;&#xFF0C;&#x9019;&#x662F;&#x7DE8;&#x8B6F;&#x4E4B;&#x524D;&#x7684;&#x6E96;&#x5099;&#x6B65;&#x9A5F;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/10/image-29.png" class="kg-image" alt="VS Code Note 02" loading="lazy" width="707" height="95" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/10/image-29.png 600w, https://ghost.augustushsu.com/content/images/2024/10/image-29.png 707w"></figure>
<p>&#x63A5;&#x8457;&#x7528;<code>CMake: Build</code>&#x7DE8;&#x8B6F;&#x5C08;&#x6848;&#xFF0C;&#x5C07;&#x6E90;&#x4EE3;&#x78BC;&#x7DE8;&#x8B6F;&#x6210;&#x53EF;&#x57F7;&#x884C;&#x6587;&#x4EF6;&#x6216;&#x5EAB;&#xFF0C;&#x662F;&#x6700;&#x7D42;&#x751F;&#x6210;&#x76EE;&#x6A19;&#x7684;&#x6B65;&#x9A5F;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/10/image-30.png" class="kg-image" alt="VS Code Note 02" loading="lazy" width="704" height="95" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/10/image-30.png 600w, https://ghost.augustushsu.com/content/images/2024/10/image-30.png 704w"></figure>
<h2 id="%E7%B5%90%E8%AA%9E">&#x7D50;&#x8A9E;</h2>
<p>&#x5728;&#x9019;&#x7BC7;&#x6587;&#x7AE0;&#x4E2D;&#xFF0C;&#x4ECB;&#x7D39;&#x4E86;&#x5982;&#x4F55;&#x4F7F;&#x7528;VSCode&#x4F86;&#x9032;&#x884C;C++&#x958B;&#x767C;&#xFF0C;&#x4E26;&#x8A73;&#x7D30;&#x8B1B;&#x89E3;&#x4E86;&#x5728;&#x7DE8;&#x8B6F;C++&#x5C08;&#x6848;&#x6642;&#x53EF;&#x80FD;&#x6703;&#x7528;&#x5230;&#x7684;&#x5404;&#x7A2E;&#x8A2D;&#x5B9A;&#xFF0C;&#x5982;<code>tasks.json</code>&#x548C;<code>launch.json</code>&#x3002;&#x540C;&#x6642;&#x4E5F;&#x521D;&#x6B65;&#x63A2;&#x8A0E;&#x4E86;CMake&#x7684;&#x4F5C;&#x7528;&#xFF0C;&#x5C55;&#x793A;&#x4E86;&#x5982;&#x4F55;&#x5229;&#x7528;&#x5B83;&#x4F86;&#x7C21;&#x5316;&#x8DE8;&#x5E73;&#x53F0;&#x7684;&#x7DE8;&#x8B6F;&#x8207;&#x914D;&#x7F6E;&#x904E;&#x7A0B;&#xFF0C;&#x900F;&#x904E;&#x9019;&#x4E9B;&#x5DE5;&#x5177;&#x548C;&#x8A2D;&#x5B9A;&#xFF0C;VSCode&#x6210;&#x70BA;&#x4E00;&#x500B;&#x9748;&#x6D3B;&#x3001;&#x9AD8;&#x6548;&#x7684;C++&#x958B;&#x767C;&#x74B0;&#x5883;&#xFF0C;&#x5E6B;&#x52A9;&#x958B;&#x767C;&#x8005;&#x66F4;&#x8F15;&#x9B06;&#x5730;&#x7BA1;&#x7406;&#x548C;&#x69CB;&#x5EFA;&#x8907;&#x96DC;&#x7684;&#x5C08;&#x6848;&#x3002;</p>]]></content:encoded></item><item><title><![CDATA[Python Note 05]]></title><description><![CDATA[<h1 id="python-%E6%97%A5%E8%AA%8C%E5%88%A9%E5%99%A8loguru">Python &#x65E5;&#x8A8C;&#x5229;&#x5668;- Loguru</h1><p>&#x5728;&#x958B;&#x767C;&#x7A0B;&#x5F0F;&#x6642;&#xFF0C;&#x8A18;&#x9304;&#x65E5;&#x8A8C;&#x662F;&#x81F3;&#x95DC;&#x91CD;&#x8981;&#x7684;&#x5DE5;&#x4F5C;&#xFF0C;&#x5C24;&#x5176;&#x5728;&#x932F;&#x8AA4;&#x6392;&#x67E5;&#x3001;&#x6548;&#x80FD;&#x512A;&#x5316;&#x3001;&#x4EE5;&#x53CA;&#x61C9;&#x7528;&#x7A0B;&#x5F0F;&#x76E3;&#x63A7;&#x7B49;&#x65B9;</p>]]></description><link>https://ghost.augustushsu.com/python-note-05/</link><guid isPermaLink="false">64c8030908c8f60331e9c9d5</guid><category><![CDATA[Python-Note]]></category><dc:creator><![CDATA[AugustusHsu]]></dc:creator><pubDate>Sun, 27 Oct 2024 12:00:45 GMT</pubDate><media:content url="https://ghost.augustushsu.com/content/images/2024/09/python-note-05.png" medium="image"/><content:encoded><![CDATA[<h1 id="python-%E6%97%A5%E8%AA%8C%E5%88%A9%E5%99%A8loguru">Python &#x65E5;&#x8A8C;&#x5229;&#x5668;- Loguru</h1><img src="https://ghost.augustushsu.com/content/images/2024/09/python-note-05.png" alt="Python Note 05"><p>&#x5728;&#x958B;&#x767C;&#x7A0B;&#x5F0F;&#x6642;&#xFF0C;&#x8A18;&#x9304;&#x65E5;&#x8A8C;&#x662F;&#x81F3;&#x95DC;&#x91CD;&#x8981;&#x7684;&#x5DE5;&#x4F5C;&#xFF0C;&#x5C24;&#x5176;&#x5728;&#x932F;&#x8AA4;&#x6392;&#x67E5;&#x3001;&#x6548;&#x80FD;&#x512A;&#x5316;&#x3001;&#x4EE5;&#x53CA;&#x61C9;&#x7528;&#x7A0B;&#x5F0F;&#x76E3;&#x63A7;&#x7B49;&#x65B9;&#x9762;&#x3002;&#x7136;&#x800C;&#x6A19;&#x6E96;&#x7684;Python logging&#x6709;&#x6642;&#x6703;&#x986F;&#x5F97;&#x904E;&#x65BC;&#x7E41;&#x7463;&#xFF0C;&#x9700;&#x8981;&#x5BEB;&#x8A31;&#x591A;&#x914D;&#x7F6E;&#x624D;&#x80FD;&#x6EFF;&#x8DB3;&#x9700;&#x6C42;&#x3002;</p><p>&#x70BA;&#x4E86;&#x7C21;&#x5316;&#x9019;&#x4E9B;&#x5DE5;&#x4F5C;&#xFF0C;Loguru &#x63D0;&#x4F9B;&#x4E86;&#x8C50;&#x5BCC;&#x7684;&#x529F;&#x80FD;&#xFF0C;&#x5982;&#x683C;&#x5F0F;&#x5316;&#x65E5;&#x8A8C;&#x3001;&#x81EA;&#x52D5;&#x8F2A;&#x66FF;&#x6A94;&#x6848;&#x3001;&#x65E5;&#x8A8C;&#x7B49;&#x7D1A;&#x63A7;&#x5236;&#x7B49;&#xFF0C;&#x9019;&#x4E9B;&#x529F;&#x80FD;&#x5C0D;&#x65BC;&#x65E5;&#x5E38;&#x958B;&#x767C;&#x548C;&#x904B;&#x7DAD;&#x90FD;&#x5341;&#x5206;&#x5BE6;&#x7528;&#x3002;</p><h2 id="%E9%96%8B%E7%AE%B1%E5%8D%B3%E7%94%A8loguru">&#x958B;&#x7BB1;&#x5373;&#x7528;Loguru</h2><p>&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x900F;&#x904E;pip&#x5B89;&#x88DD;Loguru : </p><pre><code class="language-bash">pip install loguru</code></pre><p>&#x5B89;&#x88DD;&#x5B8C;&#x5F8C;&#x5C31;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x4F7F;&#x7528;Loguru&#xFF0C;&#x7121;&#x9700;&#x984D;&#x5916;&#x7684;&#x8A2D;&#x5B9A;&#x5373;&#x53EF;&#x958B;&#x59CB;&#x8A18;&#x9304;&#x65E5;&#x8A8C;&#xFF0C;&#x4E00;&#x884C;&#x4EE3;&#x78BC;&#x5373;&#x53EF;&#x8A18;&#x9304;&#x65E5;&#x8A8C;&#xFF0C;Loguru&#x9810;&#x8A2D;&#x6703;&#x5C07;&#x65E5;&#x8A8C;&#x8F38;&#x51FA;&#x5230;Terminal:</p><pre><code class="language-python">from loguru import logger

logger.info(&apos;This is info information&apos;)</code></pre><p>&#x4E26;&#x81EA;&#x5E36;&#x683C;&#x5F0F;&#x5316;&#x986F;&#x793A;:</p><pre><code class="language-bash">2024-09-27 20:49:19.961 | INFO     | __main__:&lt;module&gt;:3 - This is info information</code></pre><h2 id="%E7%9B%B4%E8%A7%80%E4%B8%94%E7%B0%A1%E6%BD%94%E7%9A%84api">&#x76F4;&#x89C0;&#x4E14;&#x7C21;&#x6F54;&#x7684;API</h2><p>&#x524D;&#x9762;&#x6709;&#x8B1B;&#x904E;Loguru&#x9ED8;&#x8A8D;&#x6703;&#x5C07;&#x65E5;&#x8A8C;&#x8F38;&#x51FA;&#x5230;Terminal&#xFF0C;&#x5982;&#x679C;&#x8981;&#x53D6;&#x6D88;&#x9810;&#x8A2D;&#x8A2D;&#x5B9A;&#x5247;&#x9700;&#x8981;&#x900F;&#x904E;<code>logger.remove</code>&#x4F86;&#x79FB;&#x9664;&#xFF0C;<code>handler_id=None</code>&#x4EE3;&#x8868;&#x522A;&#x9664;&#x6240;&#x6709;&#x7684;logger:</p><pre><code class="language-python">logger.remove(handler_id=None)</code></pre><p>&#x5982;&#x679C;&#x8981;&#x91CD;&#x65B0;&#x8A2D;&#x5B9A;&#x56DE;&#x4F86;&#xFF0C;&#x8981;&#x5C07;<code>logger.add()</code>&#x7684;<code>sink</code>&#x8B8A;&#x6578;&#x8A2D;&#x5B9A;&#x70BA;<code>sys.stderr</code>&#x5C31;&#x80FD;&#x5728;Terminal&#x4E0A;&#x986F;&#x793A;&#xFF0C;&#x56DE;&#x50B3;&#x7684;<code>stderrLogger</code>&#x985E;&#x578B;&#x70BA;<code>int</code>&#xFF0C;&#x5728;&#x522A;&#x9664;&#x7684;&#x6642;&#x53EF;&#x4EE5;&#x5C07;<code>handler_id</code>&#x6307;&#x5B9A;&#x70BA;<code>stderrLogger</code>&#x4F86;&#x522A;&#x9664;&#xFF0C;&#x5C07;<code>stderrLogger</code>&#x7269;&#x4EF6;&#x79FB;&#x9664;&#x4E4B;&#x5F8C;&#xFF0C;&#x5728;&#x9019;&#x4E4B;&#x5F8C;&#x7684;&#x5167;&#x5BB9;&#x4E0D;&#x6703;&#x518D;&#x8F38;&#x51FA;&#x5230;&#x65E5;&#x8A8C;&#x6A94;&#x6848;:</p><pre><code class="language-python">impory sys
stderrLogger = logger.add(sink=sys.stderr, level=&quot;TRACE&quot;)
logger.remove(handler_id=stderrLogger)</code></pre><p>&#x53EF;&#x4EE5;&#x8ABF;&#x6574;&#x65E5;&#x8A8C;&#x7684;&#x7B49;&#x7D1A;&#x4F86;&#x63A7;&#x5236;&#x8F38;&#x51FA;:</p><pre><code class="language-python">from loguru import logger

logger.trace(&apos;This is debug information&apos;)
logger.debug(&apos;This is debug information&apos;)
logger.info(&apos;This is info information&apos;)
logger.success(&apos;This is info information&apos;)
logger.warning(&apos;This is warn information&apos;)
logger.error(&apos;This is error information&apos;)
logger.critical(&apos;This is error information&apos;)</code></pre><p>&#x5982;&#x679C;&#x662F;&#x5728;IDE&#x6216;Terminal&#x4E0A;&#x904B;&#x884C;&#x6703;&#x767C;&#x73FE;&#xFF0C;Loguru&#x5728;&#x8F38;&#x51FA;&#x4E0D;&#x540C;&#x7B49;&#x7D1A;&#x7684;&#x8CC7;&#x8A0A;&#x6642;&#xFF0C;&#x6703;&#x5E36;&#x4E0A;&#x4E0D;&#x540C;&#x7684;&#x984F;&#x8272;:</p><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-83.png" class="kg-image" alt="Python Note 05" loading="lazy" width="774" height="150" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-83.png 600w, https://ghost.augustushsu.com/content/images/2024/09/image-83.png 774w" sizes="(min-width: 720px) 720px"></figure><p>&#x5982;&#x679C;&#x8981;&#x5207;&#x63DB;&#x8A18;&#x9304;&#x4E0D;&#x540C;level&#x7684;log&#x6642;&#xFF0C;&#x53EF;&#x4EE5;&#x900F;&#x904E;<code>logger.add</code>&#x5728;&#x5EFA;&#x7ACB;&#x6642;&#x8A2D;&#x5B9A;:</p><pre><code class="language-python">stderrLogger = logger.add(sys.stderr, level=&quot;TRACE&quot;)</code></pre><p>&#x4EE5;&#x4E0B;&#x662F;&#x4E0D;&#x540C;log level&#x7684;&#x5C0D;&#x61C9;&#x95DC;&#x4FC2;:</p><!--kg-card-begin: markdown--><table>
<thead>
<tr>
<th style="text-align:center">Level Name</th>
<th style="text-align:center">Sererity Value</th>
<th style="text-align:center">Logger Method</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center"><code>TRACE</code></td>
<td style="text-align:center">5</td>
<td style="text-align:center"><code>logger.trace()</code></td>
</tr>
<tr>
<td style="text-align:center"><code>DEBUG</code></td>
<td style="text-align:center">10</td>
<td style="text-align:center"><code>logger.debug()</code></td>
</tr>
<tr>
<td style="text-align:center"><code>INFO</code></td>
<td style="text-align:center">20</td>
<td style="text-align:center"><code>logger.info()</code></td>
</tr>
<tr>
<td style="text-align:center"><code>SUCCESS</code></td>
<td style="text-align:center">25</td>
<td style="text-align:center"><code>logger.success()</code></td>
</tr>
<tr>
<td style="text-align:center"><code>WARNING</code></td>
<td style="text-align:center">30</td>
<td style="text-align:center"><code>logger.warning()</code></td>
</tr>
<tr>
<td style="text-align:center"><code>ERROR</code></td>
<td style="text-align:center">40</td>
<td style="text-align:center"><code>logger.error()</code></td>
</tr>
<tr>
<td style="text-align:center"><code>CRITICAL</code></td>
<td style="text-align:center">50</td>
<td style="text-align:center"><code>logger.critical()</code></td>
</tr>
</tbody>
</table>
<!--kg-card-end: markdown--><h2 id="%E8%87%AA%E5%AE%9A%E7%BE%A9%E6%97%A5%E8%AA%8C%E6%A0%BC%E5%BC%8F">&#x81EA;&#x5B9A;&#x7FA9;&#x65E5;&#x8A8C;&#x683C;&#x5F0F;</h2><p>&#x5728;&#x4F7F;&#x7528;Loguru&#x8A18;&#x9304;&#x65E5;&#x8A8C;&#x6642;&#xFF0C;&#x81EA;&#x8A02;&#x65E5;&#x8A8C;&#x7684;&#x5132;&#x5B58;&#x6A94;&#x6848;&#x540D;&#x7A31;&#x8207;&#x65E5;&#x8A8C;&#x7684;&#x683C;&#x5F0F;&#x5316;&#x662F;&#x5E38;&#x898B;&#x9700;&#x6C42;&#xFF0C;Loguru&#x63D0;&#x4F9B;&#x4E86;&#x975E;&#x5E38;&#x9748;&#x6D3B;&#x4E14;&#x76F4;&#x89C0;&#x7684;&#x65B9;&#x5F0F;&#x4F86;&#x5BE6;&#x73FE;&#x9019;&#x5169;&#x500B;&#x9700;&#x6C42;&#xFF0C;&#x8B93;&#x958B;&#x767C;&#x8005;&#x80FD;&#x5920;&#x4F9D;&#x64DA;&#x61C9;&#x7528;&#x5834;&#x666F;&#xFF0C;&#x78BA;&#x4FDD;&#x65E5;&#x8A8C;&#x6587;&#x4EF6;&#x7684;&#x547D;&#x540D;&#x6E05;&#x6670;&#x3001;&#x5167;&#x5BB9;&#x8C50;&#x5BCC;&#x4E14;&#x5177;&#x53EF;&#x8B80;&#x6027;&#x3002;</p><h3 id="%E8%87%AA%E5%AE%9A%E7%BE%A9%E5%90%8D%E7%A8%B1">&#x81EA;&#x5B9A;&#x7FA9;&#x540D;&#x7A31;</h3><p>&#x5C07;&#x65E5;&#x8A8C;&#x5BEB;&#x5165;&#x6587;&#x4EF6;&#x6642;&#xFF0C;&#x81EA;&#x8A02;&#x6587;&#x4EF6;&#x540D;&#x7A31;&#x53EF;&#x4EE5;&#x5E6B;&#x52A9;&#x4F60;&#x7D44;&#x7E54;&#x548C;&#x7BA1;&#x7406;&#x65E5;&#x8A8C;&#x6587;&#x4EF6;&#xFF0C;Loguru &#x5141;&#x8A31;&#x5728;&#x6587;&#x4EF6;&#x540D;&#x7A31;&#x4E2D;&#x4F7F;&#x7528;&#x8B8A;&#x91CF;&#xFF0C;&#x7279;&#x5225;&#x662F;&#x5229;&#x7528;&#x6642;&#x9593;&#x6233;&#x4F86;&#x52D5;&#x614B;&#x7522;&#x751F;&#x6587;&#x4EF6;&#x540D;&#xFF0C;&#x9019;&#x5C0D;&#x65BC;&#x9700;&#x8981;&#x6839;&#x64DA;&#x65E5;&#x671F;&#x6216;&#x6642;&#x9593;&#x9032;&#x884C;&#x65E5;&#x8A8C;&#x8F2A;&#x66FF;&#x7684;&#x61C9;&#x7528;&#x975E;&#x5E38;&#x6709;&#x7528;&#x3002;</p><p>&#x4F7F;&#x7528;<code>{time}</code>&#x4F86;&#x547D;&#x540D;&#x6A94;&#x6848;&#xFF0C;&#x6703;&#x81EA;&#x52D5;&#x66FF;&#x63DB;<code>{time}</code>&#x70BA;&#x65E5;&#x8A8C;&#x8A18;&#x9304;&#x7684;&#x7576;&#x524D;&#x6642;&#x9593;&#xFF0C;&#x6700;&#x7D42;&#x7522;&#x751F;&#x7684;&#x6A94;&#x6848;&#x540D;&#x7A31;&#x53EF;&#x80FD;&#x6703;&#x985E;&#x4F3C;&#x65BC;<code>logs/log_2024-09-27_12-34-56.log:</code></p><pre><code class="language-python"># &#x4F7F;&#x7528;&#x65E5;&#x671F;&#x6642;&#x9593;&#x4F5C;&#x70BA;&#x6A94;&#x6848;&#x540D;&#x7A31;&#x7684;&#x4E00;&#x90E8;&#x5206;
logger.add(&quot;logs/log_{time}.log&quot;)</code></pre><p>&#x4E5F;&#x53EF;&#x4EE5;&#x81EA;&#x5B9A;&#x7FA9;&#x6642;&#x9593;&#x683C;&#x5F0F;&#xFF0C;&#x900F;&#x904E;&#x4F7F;&#x7528;<code>time.strftime</code>&#x7684;&#x6642;&#x9593;&#x683C;&#x5F0F;&#x5316;&#x898F;&#x5247;&#x4F86;&#x5B8C;&#x6210;&#xFF0C;&#x6BCF;&#x5929;&#x7684;&#x65E5;&#x8A8C;&#x90FD;&#x6703;&#x5132;&#x5B58;&#x5728;&#x4E0D;&#x540C;&#x7684;&#x6A94;&#x6848;&#x4E2D;&#xFF0C;&#x50C5;&#x6839;&#x64DA;&#x65E5;&#x671F;&#x9032;&#x884C;&#x8F2A;&#x63DB;&#x3002; :</p><pre><code class="language-python"># &#x81EA;&#x5B9A;&#x7FA9;&#x6642;&#x9593;&#x683C;&#x5F0F;
logger.add(&quot;logs/log_{time:YYYY-MM-DD}.log</code></pre><p>&#x9664;&#x4E86;&#x6642;&#x9593;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x5728;&#x6A94;&#x6848;&#x540D;&#x7A31;&#x4E2D;&#x4F7F;&#x7528;&#x66F4;&#x591A;&#x81EA;&#x8A02;&#x5167;&#x5BB9;&#xFF0C;&#x4F8B;&#x5982;&#x9032;&#x7A0B;ID&#x3001;&#x65E5;&#x8A8C;&#x7B49;&#x7D1A;&#x7B49;&#x4F86;&#x7522;&#x751F;&#x6709;&#x610F;&#x7FA9;&#x7684;&#x6A94;&#x6848;&#x540D;&#x7A31;&#xFF0C;&#x9019;&#x5C0D;&#x65BC;&#x9700;&#x8981;&#x8A18;&#x9304;&#x591A;&#x9032;&#x7A0B;&#x61C9;&#x7528;&#x7A0B;&#x5F0F;&#x7684;&#x65E5;&#x8A8C;&#x6642;&#x7279;&#x5225;&#x6709;&#x7528;&#xFF1A;</p><pre><code class="language-python"># &#x5176;&#x4ED6;&#x6A94;&#x6848;&#x540D;&#x7A31;&#x683C;&#x5F0F;&#x8B8A;&#x91CF;
logger.add(&quot;logs/log_{time}_{level}_{process}.log&quot;)</code></pre><h3 id="%E8%87%AA%E5%AE%9A%E7%BE%A9%E6%A0%BC%E5%BC%8F">&#x81EA;&#x5B9A;&#x7FA9;&#x683C;&#x5F0F;</h3><p><code>format</code>&#x53C3;&#x6578;&#x5141;&#x8A31;&#x81EA;&#x5B9A;&#x7FA9;&#x6BCF;&#x689D;&#x65E5;&#x8A8C;&#x7684;&#x8F38;&#x51FA;&#x683C;&#x5F0F;&#xFF0C;&#x5C0D;&#x65BC;&#x63D0;&#x5347;&#x65E5;&#x8A8C;&#x7684;&#x53EF;&#x8B80;&#x6027;&#x4EE5;&#x53CA;&#x8B93;&#x65E5;&#x8A8C;&#x5167;&#x5BB9;&#x66F4;&#x52A0;&#x6709;&#x7528;&#x662F;&#x975E;&#x5E38;&#x6709;&#x7528;&#x7684;&#xFF0C;Loguru&#x63D0;&#x4F9B;&#x4E86;&#x4E00;&#x7CFB;&#x5217;&#x7684;&#x5167;&#x7F6E;&#x8B8A;&#x91CF;&#xFF0C;&#x53EF;&#x4EE5;&#x5728;&#x4E2D;<code>format</code>&#x4F7F;&#x7528;&#x4F86;&#x63A7;&#x5236;&#x6BCF;&#x689D;&#x65E5;&#x8A8C;&#x7684;&#x8F38;&#x51FA;&#x6A23;&#x5F0F;&#x3002;</p><p>&#x53EF;&#x4EE5;&#x900F;&#x904E;<code>format</code>&#x4F86;&#x63A7;&#x5236;&#x65E5;&#x8A8C;&#x8F38;&#x51FA;&#x7684;&#x683C;&#x5F0F;&#xFF0C;&#x5305;&#x62EC;&#x6642;&#x9593;&#x3001;&#x65E5;&#x8A8C;&#x7B49;&#x7D1A;&#x3001;&#x8A0A;&#x606F;&#x5167;&#x5BB9;&#x7B49;:</p><pre><code class="language-python">logger.add(&quot;logs/log.log&quot;, format=&quot;{time} {level} {message}&quot;)
logger.info(&apos;This is info information&apos;)</code></pre><p>&#x9019;&#x500B;&#x7BC4;&#x4F8B;&#x7684;&#x65E5;&#x8A8C;&#x8F38;&#x51FA;&#x683C;&#x5F0F;&#x6703;&#x986F;&#x793A;&#x6642;&#x9593;&#x3001;&#x65E5;&#x8A8C;&#x7B49;&#x7D1A;&#x548C;&#x8A0A;&#x606F;&#x5167;&#x5BB9;&#xFF0C;&#x6700;&#x7D42;&#x7684;&#x65E5;&#x8A8C;&#x53EF;&#x80FD;&#x770B;&#x8D77;&#x4F86;&#x50CF;&#x9019;&#x6A23;:</p><pre><code class="language-bash">2024-09-28T13:44:58.839276+0000 INFO This is info information</code></pre><p>Loguru &#x652F;&#x63F4;&#x591A;&#x7A2E;&#x683C;&#x5F0F;&#x5316;&#x8B8A;&#x91CF;&#xFF0C;&#x53EF;&#x4EE5;&#x81EA;&#x7531;&#x7D44;&#x5408;&#x5EFA;&#x7ACB;&#x9069;&#x5408;&#x81EA;&#x5DF1;&#x7684;&#x65E5;&#x8A8C;&#x8F38;&#x51FA;&#x683C;&#x5F0F;&#xFF1A;</p><!--kg-card-begin: markdown--><table>
<thead>
<tr>
<th style="text-align:left">&#x8B8A;&#x91CF;</th>
<th style="text-align:left">&#x8B8A;&#x91CF;&#x8AAA;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><code>{time}</code></td>
<td style="text-align:left">&#x8A72;Log&#x8A18;&#x9304;&#x7684;&#x6642;&#x9593;&#xFF0C;&#x9ED8;&#x8A8D;&#x683C;&#x5F0F;&#x70BA; YYYY-MM-DD HH:mm:ss</td>
</tr>
<tr>
<td style="text-align:left"><code>{level}</code></td>
<td style="text-align:left">Log&#x7B49;&#x7D1A;&#xFF08;&#x5982; DEBUG&#x3001;INFO&#x3001;WARNING&#x3001;ERROR&#xFF09;</td>
</tr>
<tr>
<td style="text-align:left"><code>{message}</code></td>
<td style="text-align:left">Log&#x8A0A;&#x606F;&#x5167;&#x5BB9;</td>
</tr>
<tr>
<td style="text-align:left"><code>{name}</code></td>
<td style="text-align:left">&#x8A72;Log&#x7522;&#x751F;&#x7684;&#x8A18;&#x9304;&#x5668;&#x540D;&#x7A31;</td>
</tr>
<tr>
<td style="text-align:left"><code>{file}</code></td>
<td style="text-align:left">&#x7576;&#x524D;&#x7A0B;&#x5F0F;&#x78BC;&#x6A94;&#x6848;&#x540D;&#x7A31;</td>
</tr>
<tr>
<td style="text-align:left"><code>{line}</code></td>
<td style="text-align:left">&#x8A72;Log&#x6240;&#x5728;&#x7684;&#x7A0B;&#x5F0F;&#x78BC;&#x884C;&#x865F;</td>
</tr>
<tr>
<td style="text-align:left"><code>{function}</code></td>
<td style="text-align:left">&#x8A18;&#x9304;&#x8A72;Log&#x7684;&#x51FD;&#x6578;&#x540D;&#x7A31;</td>
</tr>
<tr>
<td style="text-align:left"><code>{thread}</code></td>
<td style="text-align:left">&#x8A18;&#x9304;&#x8A72;Log&#x7684;thread ID</td>
</tr>
<tr>
<td style="text-align:left"><code>{process}</code></td>
<td style="text-align:left">&#x8A18;&#x9304;&#x8A72;Log&#x7684;process ID</td>
</tr>
</tbody>
</table>
<!--kg-card-end: markdown--><p>&#x5982;&#x679C;&#x5E0C;&#x671B;&#x5728;&#x65E5;&#x8A8C;&#x4E2D;&#x986F;&#x793A;<strong>&#x6A94;&#x6848;&#x540D;&#x7A31;</strong>&#x3001;<strong>&#x884C;&#x865F;</strong>&#x4EE5;&#x53CA;<strong>&#x51FD;&#x6578;&#x540D;&#x7A31;</strong>&#xFF0C;&#x9019;&#x4E9B;&#x8CC7;&#x8A0A;&#x53EF;&#x4EE5;&#x5728;&#x5927;&#x578B;&#x5C08;&#x6848;&#x4E2D;&#x66F4;&#x5FEB;&#x5730;&#x5B9A;&#x4F4D;Bug&#x6216;Debug&#x554F;&#x984C;:</p><pre><code class="language-python">logger.add(&quot;logs/log.log&quot;, format=&quot;{time} {level} {file}:{line} - {function} - {message}&quot;)
logger.info(&apos;This is info information&apos;)</code></pre><p>&#x9019;&#x6A23;&#x7684;&#x65E5;&#x8A8C;&#x8F38;&#x51FA;&#x6703;&#x5305;&#x542B;&#x8A73;&#x7D30;&#x7684;Debug&#x8A0A;&#x606F;:</p><pre><code class="language-bash">2024-09-28T13:46:25.002661+0000 INFO main.py:4 - &lt;module&gt; - This is info information</code></pre><p>&#x5982;&#x679C;&#x6B63;&#x5728;&#x958B;&#x767C;&#x591A;&#x7DDA;&#x7A0B;&#x6216;&#x591A;&#x9032;&#x7A0B;&#x61C9;&#x7528;&#xFF0C;&#x8A18;&#x9304;thread&#x548C;process&#x8CC7;&#x8A0A;&#x80FD;&#x5920;&#x66F4;&#x597D;&#x5730;&#x7406;&#x89E3;&#x65E5;&#x8A8C;&#x7684;&#x4E0A;&#x4E0B;&#x6587;&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;<code>{thread}</code>&#x548C;<code>{process}</code>&#x4F86;&#x986F;&#x793A;<strong>thread ID</strong>&#x548C;<strong>process ID</strong> :</p><pre><code class="language-python">logger.add(&quot;logs/log.log&quot;, format=&quot;{time} {level} {process} {thread} {message}&quot;)
logger.info(&apos;This is info information&apos;)</code></pre><p>&#x9019;&#x6A23;&#x7684;&#x65E5;&#x8A8C;&#x8F38;&#x51FA;&#x6703;&#x5305;&#x542B;thread&#x548C;process&#x7684;&#x8CC7;&#x8A0A;&#xFF1B;</p><pre><code class="language-bash">2024-09-28T13:48:08.821860+0000 INFO 2827 139391729250304 This is info information
</code></pre><h2 id="%E8%87%AA%E5%8B%95%E6%AA%94%E6%A1%88%E8%BC%AA%E6%8F%9B">&#x81EA;&#x52D5;&#x6A94;&#x6848;&#x8F2A;&#x63DB;</h2><p>&#x5728;&#x65E5;&#x8A8C;&#x7BA1;&#x7406;&#x4E2D;&#xFF0C;&#x63A7;&#x5236;&#x65E5;&#x8A8C;&#x6A94;&#x6848;&#x7684;&#x5927;&#x5C0F;&#x3001;&#x6642;&#x9593;&#x9593;&#x9694;&#x6216;&#x7E3D;&#x6A94;&#x6848;&#x6578;&#x91CF;&#x662F;&#x975E;&#x5E38;&#x91CD;&#x8981;&#x7684;&#x529F;&#x80FD;&#xFF0C;&#x7279;&#x5225;&#x662F;&#x5728;&#x9577;&#x6642;&#x9593;&#x904B;&#x884C;&#x7684;&#x61C9;&#x7528;&#x4E2D;&#xFF0C;&#x904E;&#x5927;&#x7684;&#x65E5;&#x8A8C;&#x6A94;&#x6848;&#x4E0D;&#x50C5;&#x96E3;&#x4EE5;&#x7BA1;&#x7406;&#xFF0C;&#x9084;&#x6703;&#x5F71;&#x97FF;&#x7CFB;&#x7D71;&#x6548;&#x80FD;&#xFF0C;Loguru&#x63D0;&#x4F9B;&#x4E86;&#x5167;&#x7F6E;&#x7684;<strong>rotation (&#x6A94;&#x6848;&#x8F2A;&#x63DB;)</strong>&#x8207;<strong>retention (&#x4FDD;&#x7559;)</strong>&#x529F;&#x80FD;&#xFF0C;&#x652F;&#x63F4;&#x81EA;&#x52D5;&#x5C07;&#x65E5;&#x8A8C;&#x6A94;&#x6848;&#x8F2A;&#x63DB;&#x5B58;&#x6A94;&#xFF0C;&#x4E26;&#x4E14;&#x53EF;&#x4EE5;&#x6839;&#x64DA;&#x6A94;&#x6848;&#x5927;&#x5C0F;&#x3001;&#x6642;&#x9593;&#x9593;&#x9694;&#x6216;&#x6A94;&#x6848;&#x6578;&#x91CF;&#x9032;&#x884C;&#x63A7;&#x5236;&#x3002;</p><h3 id="rotation">Rotation</h3><p>&#x7576;&#x9054;&#x5230;&#x4E00;&#x5B9A;&#x7684;&#x689D;&#x4EF6;(&#x5982;<strong>&#x6A94;&#x6848;&#x5927;&#x5C0F;</strong>&#x3001;<strong>&#x6642;&#x9593;&#x9593;&#x9694;</strong>&#x6642;)&#xFF0C;&#x81EA;&#x52D5;&#x5C07;&#x76EE;&#x524D;&#x65E5;&#x8A8C;&#x6A94;&#x6848;&#x95DC;&#x9589;&#x4E26;&#x5EFA;&#x7ACB;&#x65B0;&#x7684;&#x6A94;&#x6848;:</p><pre><code class="language-python"># &#x7576;&#x6587;&#x4EF6;&#x5927;&#x5C0F;&#x8D85;&#x904E; 10 MB &#x6642;&#x6703;&#x81EA;&#x52D5;&#x5275;&#x5EFA;&#x4E00;&#x500B;&#x65B0;&#x7684;&#x65E5;&#x8A8C;&#x6587;&#x4EF6;
logger.add(&quot;file_{time}.log&quot;, rotation=&quot;10 MB&quot;)

# &#x6BCF;&#x5929;&#x534A;&#x591C;&#x81EA;&#x52D5;&#x5275;&#x5EFA;&#x4E00;&#x500B;&#x65B0;&#x7684;&#x65E5;&#x8A8C;&#x6587;&#x4EF6;
logger.add(&quot;file_{time}.log&quot;, rotation=&quot;00:00&quot;)

# &#x4E5F;&#x53EF;&#x4EE5;&#x6307;&#x5B9A;&#x5176;&#x4ED6;&#x6642;&#x9593;&#x9593;&#x9694;&#x4F86;&#x9032;&#x884C;&#x8F2A;&#x66FF; &#x4F8B;&#x5982;&#x6BCF;&#x5C0F;&#x6642;&#x3001;&#x6BCF;&#x5206;&#x9418;&#x7B49;
# &#x6BCF;&#x5C0F;&#x6642;&#x81EA;&#x52D5;&#x5275;&#x5EFA;&#x4E00;&#x500B;&#x65B0;&#x7684;&#x65E5;&#x8A8C;&#x6587;&#x4EF6;
logger.add(&quot;file_{time}.log&quot;, rotation=&quot;1 hour&quot;)</code></pre><h3 id="retention">Retention</h3><p>&#x6839;&#x64DA;&#x7279;&#x5B9A;&#x689D;&#x4EF6;&#x6C7A;&#x5B9A;&#x8981;&#x4FDD;&#x7559;&#x7684;<strong>&#x65E5;&#x8A8C;&#x6A94;&#x6848;&#x6578;&#x91CF;</strong>&#x6216;<strong>&#x6642;&#x9593;&#x7BC4;&#x570D;</strong>&#xFF0C;&#x8D85;&#x51FA;&#x7BC4;&#x570D;&#x7684;&#x820A;&#x65E5;&#x8A8C;&#x6A94;&#x6848;&#x6703;&#x81EA;&#x52D5;&#x522A;&#x9664;&#xFF0C;&#x9632;&#x6B62;&#x6A94;&#x6848;&#x6578;&#x91CF;&#x904E;&#x591A;&#x4F54;&#x7528;&#x904E;&#x591A;&#x5132;&#x5B58;&#x7A7A;&#x9593;:</p><pre><code class="language-python"># &#x4FDD;&#x7559;&#x6700;&#x8FD1; 10 &#x500B;&#x65E5;&#x8A8C;&#x6587;&#x4EF6; &#x8D85;&#x904E;&#x90E8;&#x5206;&#x81EA;&#x52D5;&#x522A;&#x9664;
logger.add(&quot;file_{time}.log&quot;, retention=10)

# &#x4FDD;&#x7559;&#x6700;&#x8FD1; 7 &#x5929;&#x7684;&#x65E5;&#x8A8C;&#x6587;&#x4EF6;
logger.add(&quot;file_{time}.log&quot;, retention=&quot;7 days&quot;)</code></pre><h3 id="compression">Compression</h3><p>Loguru&#x9084;&#x63D0;&#x4F9B;&#x4E86;&#x58D3;&#x7E2E;&#x529F;&#x80FD;&#xFF0C;&#x7576;&#x65E5;&#x8A8C;&#x8F2A;&#x66FF;&#x5F8C;&#xFF0C;&#x820A;&#x65E5;&#x8A8C;&#x5C07;&#x6703;&#x81EA;&#x52D5;&#x58D3;&#x7E2E;&#x70BA;<code>.zip</code>&#x683C;&#x5F0F;&#xFF0C;&#x4EE5;&#x7BC0;&#x7701;&#x7A7A;&#x9593;&#xFF0C;&#x4F7F;&#x7528;<code>compression</code>&#x53C3;&#x6578;&#x4F86;&#x555F;&#x7528;&#x6B64;&#x529F;&#x80FD;:</p><pre><code class="language-python"># &#x540C;&#x6642;&#x4F7F;&#x7528;rotation&#x548C;retention &#x4EE5;&#x5BE6;&#x73FE;&#x66F4;&#x52A0;&#x9748;&#x6D3B;&#x7684;&#x65E5;&#x8A8C;&#x7BA1;&#x7406;
# &#x6BCF;&#x5929;&#x534A;&#x591C;&#x8F2A;&#x66FF; &#x4FDD;&#x7559; 7 &#x5929;&#x7684;&#x6587;&#x4EF6; &#x4E26;&#x5C07;&#x820A;&#x6587;&#x4EF6;&#x58D3;&#x7E2E;&#x70BA; .zip &#x683C;&#x5F0F;
logger.add(&quot;file_{time}.log&quot;, rotation=&quot;00:00&quot;, retention=&quot;7 days&quot;, compression=&quot;zip&quot;)</code></pre><h2 id="loggercatch">logger.catch</h2><p>Loguru&#x63D0;&#x4F9B;&#x4E86;&#x4E00;&#x500B;&#x975E;&#x5E38;&#x65B9;&#x4FBF;&#x4E14;&#x5F37;&#x5927;&#x7684;&#x529F;&#x80FD;&#xFF0C;&#x5C31;&#x662F;&#x900F;&#x904E;&#x51FD;&#x6578;&#x88DD;&#x98FE;&#x5668;&#x4F86;&#x81EA;&#x52D5;&#x8655;&#x7406;&#x932F;&#x8AA4;&#x548C;&#x8A18;&#x9304;&#x65E5;&#x8A8C;&#xFF0C;&#x9019;&#x7279;&#x5225;&#x9069;&#x7528;&#x65BC;&#x60F3;&#x8981;&#x81EA;&#x52D5;&#x8A18;&#x9304;&#x51FD;&#x6578;&#x9032;&#x51FA;&#x3001;&#x932F;&#x8AA4;&#x5806;&#x758A;&#x8FFD;&#x8E64;&#x3001;&#x4EE5;&#x53CA;&#x907F;&#x514D;&#x672A;&#x6355;&#x6349;&#x7570;&#x5E38;&#x5C0E;&#x81F4;&#x7A0B;&#x5E8F;&#x5D29;&#x6F70;&#x7684;&#x5834;&#x666F;&#xFF0C;<code>logger.catch()</code>&#x662F;&#x9019;&#x9805;&#x529F;&#x80FD;&#x7684;&#x6838;&#x5FC3;&#xFF0C;&#x53EF;&#x4EE5;&#x7C21;&#x5316;&#x932F;&#x8AA4;&#x8655;&#x7406;&#xFF0C;&#x4E26;&#x81EA;&#x52D5;&#x8A18;&#x9304;&#x7A0B;&#x5F0F;&#x4E2D;&#x7684;&#x7570;&#x5E38;&#x3002;</p><h3 id="%E8%87%AA%E5%8B%95%E6%8D%95%E6%8D%89%E7%95%B0%E5%B8%B8">&#x81EA;&#x52D5;&#x6355;&#x6349;&#x7570;&#x5E38;</h3><p>&#x76F4;&#x63A5;&#x4F7F;&#x7528; <code>@logger.catch</code> &#x4F5C;&#x70BA;&#x51FD;&#x6578;&#x7684;&#x88DD;&#x98FE;&#x5668;&#xFF0C;&#x9019;&#x6A23;&#x7576;&#x7A0B;&#x5F0F;&#x78BC;&#x4E2D;&#x51FA;&#x73FE;&#x672A;&#x8655;&#x7406;&#x7684;&#x7570;&#x5E38;&#x6642;&#xFF0C;Loguru&#x6703;&#x81EA;&#x52D5;&#x6355;&#x6349;&#x4E26;&#x8A18;&#x9304;&#x7570;&#x5E38;&#xFF0C;&#x800C;&#x7A0B;&#x5F0F;&#x4E0D;&#x6703;&#x5D29;&#x6F70;:</p><pre><code class="language-python">from loguru import logger

@logger.catch
def divide(a, b):
    return a / b

divide(10, 0)
print(&quot;-----Keep Running-----&quot;)</code></pre><p>&#x5728;&#x4E0A;&#x9762;&#x4F8B;&#x5B50;&#x4E2D;&#xFF0C;<code>divide()</code>&#x51FD;&#x6578;&#x5F15;&#x767C;&#x4E86;<code>ZeroDivisionError</code>&#xFF0C;&#x7531;&#x65BC;&#x4F7F;&#x7528;&#x4E86;<code>logger.catch()</code>&#xFF0C;&#x9019;&#x500B;&#x7570;&#x5E38;&#x6703;&#x88AB;&#x6355;&#x6349;&#xFF0C;&#x4E26;&#x5B8C;&#x6574;&#x8A18;&#x9304;&#x5728;&#x65E5;&#x8A8C;&#x4E2D;&#xFF0C;&#x8F38;&#x51FA;&#x7684;&#x65E5;&#x8A8C;&#x5C07;&#x5305;&#x542B;&#x8A73;&#x7D30;&#x7684;&#x932F;&#x8AA4;&#x548C;&#x5806;&#x758A;&#x8FFD;&#x8E64;&#x7684;&#x8A0A;&#x606F;:</p><pre><code class="language-bash">2024-09-28 13:50:36.823 | ERROR    | __main__:&lt;module&gt;:7 - An error has been caught in function &apos;&lt;module&gt;&apos;, process &apos;MainProcess&apos; (3438), thread &apos;MainThread&apos; (140529672212480):
Traceback (most recent call last):

&gt; File &quot;/content/main.py&quot;, line 7, in &lt;module&gt;
    divide(10, 0)
    &#x2514; &lt;function divide at 0x7fcf9c3e24d0&gt;

  File &quot;/content/main.py&quot;, line 5, in divide
    return a / b
           &#x2502;   &#x2514; 0
           &#x2514; 10

ZeroDivisionError: division by zero
-----Keep Running-----</code></pre><p>&#x9019;&#x7A2E;&#x65B9;&#x5F0F;&#x4E0D;&#x50C5;&#x80FD;&#x8A18;&#x9304;&#x7570;&#x5E38;&#xFF0C;&#x9084;&#x80FD;&#x5305;&#x542B;&#x8A73;&#x7D30;&#x7684;&#x5806;&#x758A;&#x8FFD;&#x8E64;&#x4FE1;&#x606F;&#xFF0C;&#x80FD;&#x5FEB;&#x901F;&#x5B9A;&#x4F4D;&#x554F;&#x984C;&#x3002;</p><h3 id="%E4%BF%9D%E8%AD%B7%E7%A8%8B%E5%BC%8F%E7%A2%BC%E5%8D%80%E5%A1%8A">&#x4FDD;&#x8B77;&#x7A0B;&#x5F0F;&#x78BC;&#x5340;&#x584A;</h3><p>&#x9664;&#x4E86;&#x7528;&#x4F5C;&#x51FD;&#x6578;&#x88DD;&#x98FE;&#x5668;&#xFF0C;<code>logger.catch()</code>&#x9084;&#x53EF;&#x4EE5;&#x7528;&#x4F86;&#x4FDD;&#x8B77;&#x6574;&#x500B;&#x61C9;&#x7528;&#x7A0B;&#x5F0F;&#x6216;&#x4E00;&#x5927;&#x6BB5;&#x7A0B;&#x5F0F;&#x78BC;&#xFF0C;&#x800C;&#x4E0D;&#x50C5;&#x50C5;&#x662F;&#x51FD;&#x6578;&#xFF0C;&#x9019;&#x6A23;&#x53EF;&#x4EE5;&#x78BA;&#x4FDD;&#x5728;&#x67D0;&#x6BB5;&#x7A0B;&#x5F0F;&#x78BC;&#x904B;&#x884C;&#x904E;&#x7A0B;&#x4E2D;&#xFF0C;&#x4EFB;&#x4F55;&#x672A;&#x8655;&#x7406;&#x7684;&#x7570;&#x5E38;&#x90FD;&#x6703;&#x88AB;&#x6355;&#x6349;&#x4E26;&#x8A18;&#x9304;&#x4E0B;&#x4F86;&#xFF0C;&#x5F9E;&#x800C;&#x9632;&#x6B62;&#x4EFB;&#x4F55;&#x7570;&#x5E38;&#x5F71;&#x97FF;&#x6574;&#x9AD4;&#x7A0B;&#x5F0F;:</p><pre><code class="language-python">from loguru import logger

logger.add(&quot;error.log&quot;)  # &#x5C07;&#x65E5;&#x8A8C;&#x5BEB;&#x5165;&#x6A94;&#x6848;

def main():
    with logger.catch():
        10 / 0  # &#x6545;&#x610F;&#x5F15;&#x767C;&#x9664;&#x96F6;&#x932F;&#x8AA4;

main()
</code></pre><p>&#x5728;&#x4E0A;&#x9762;&#x7684;&#x7BC4;&#x4F8B;&#x4E2D;&#xFF0C;&#x7576;&#x7A0B;&#x5F0F;&#x5F15;&#x767C;&#x9664;&#x96F6;&#x932F;&#x8AA4;&#x6642;&#xFF0C;<code>logger.catch()</code>&#x6703;&#x81EA;&#x52D5;&#x6355;&#x6349;&#x4E26;&#x5C07;&#x932F;&#x8AA4;&#x8A18;&#x9304;&#x5230;<code>error.log</code>&#x4E2D;&#xFF0C;&#x800C;&#x4E0D;&#x662F;&#x8B93;&#x7A0B;&#x5F0F;&#x5D29;&#x6F70;&#x3002;&#x9019;&#x6A23;&#x7684;&#x4F7F;&#x7528;&#x65B9;&#x5F0F;&#x975E;&#x5E38;&#x9069;&#x5408;&#x90A3;&#x4E9B;&#x7121;&#x6CD5;&#x901A;&#x904E;&#x51FD;&#x6578;&#x88DD;&#x98FE;&#x5668;&#x76F4;&#x63A5;&#x6355;&#x6349;&#x7684;&#x4EE3;&#x78BC;&#x584A;&#xFF0C;&#x4F8B;&#x5982;&#x67D0;&#x500B;&#x51FD;&#x6578;&#x5167;&#x7684;&#x591A;&#x500B;&#x908F;&#x8F2F;&#x5206;&#x652F;&#x6216;&#x591A;&#x500B;&#x7570;&#x6B65;&#x64CD;&#x4F5C;:</p><pre><code class="language-bash">2024-09-28 14:00:49.070 | ERROR    | __main__:main:6 - An error has been caught in function &apos;main&apos;, process &apos;MainProcess&apos; (5877), thread &apos;MainThread&apos; (137382592274432):
Traceback (most recent call last):

  File &quot;/content/main.py&quot;, line 9, in &lt;module&gt;
    main()
    &#x2514; &lt;function main at 0x7cf2e063fd90&gt;

&gt; File &quot;/content/main.py&quot;, line 7, in main
    10 / 0  # &#x6545;&#x610F;&#x5F15;&#x767C;&#x9664;&#x96F6;&#x932F;&#x8AA4;

ZeroDivisionError: division by zero</code></pre><h3 id="%E5%BC%B7%E5%A4%A7%E7%9A%84%E5%8F%83%E6%95%B8%E6%8E%A7%E5%88%B6">&#x5F37;&#x5927;&#x7684;&#x53C3;&#x6578;&#x63A7;&#x5236;</h3><p><code>logger.catch()</code> &#x63D0;&#x4F9B;&#x4E86;&#x4E00;&#x4E9B;&#x9032;&#x968E;&#x53C3;&#x6578;&#x4F86;&#x9032;&#x4E00;&#x6B65;&#x63A7;&#x5236;&#x7570;&#x5E38;&#x8655;&#x7406;&#x7684;&#x884C;&#x70BA;&#x3002;</p><p><strong><code>reraise</code> &#x91CD;&#x65B0;&#x5F15;&#x767C;&#x7570;&#x5E38;</strong></p><p>&#x5982;&#x679C;&#x5728;&#x8A18;&#x9304;&#x5B8C;&#x932F;&#x8AA4;&#x4E4B;&#x5F8C;&#xFF0C;&#x5E0C;&#x671B;&#x5C07;&#x7570;&#x5E38;&#x91CD;&#x65B0;&#x5F15;&#x767C; (&#x8B93;&#x4E0A;&#x5C64;&#x7684;&#x4EE3;&#x78BC;&#x4E5F;&#x80FD;&#x8655;&#x7406;&#x8A72;&#x7570;&#x5E38;)&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528; <code>reraise=True</code> &#x53C3;&#x6578;:</p><pre><code class="language-python">from loguru import logger

@logger.catch(reraise=True)
def divide(a, b):
    return a / b

try:
    divide(10, 0)
except ZeroDivisionError:
    print(&quot;&#x6355;&#x6349;&#x5230;&#x9664;&#x96F6;&#x7570;&#x5E38;&quot;)</code></pre><p><code>reraise=True</code>&#x6703;&#x5728;&#x6355;&#x6349;&#x5230;&#x7570;&#x5E38;&#x5F8C;&#xFF0C;&#x91CD;&#x65B0;&#x5F15;&#x767C;<code>ZeroDivisionError</code>&#xFF0C;&#x4F7F;&#x5F97;&#x5916;&#x90E8;&#x7684;<code>try-except</code>&#x5340;&#x584A;&#x4E5F;&#x53EF;&#x4EE5;&#x8655;&#x7406;&#x9019;&#x500B;&#x7570;&#x5E38;:</p><pre><code class="language-bash">2024-09-28 14:09:04.104 | ERROR    | __main__:&lt;module&gt;:8 - An error has been caught in function &apos;&lt;module&gt;&apos;, process &apos;MainProcess&apos; (7869), thread &apos;MainThread&apos; (134771338235904):
Traceback (most recent call last):

&gt; File &quot;/content/main.py&quot;, line 8, in &lt;module&gt;
    divide(10, 0)
    &#x2514; &lt;function divide at 0x7a92e36d5f30&gt;

  File &quot;/content/main.py&quot;, line 5, in divide
    return a / b
           &#x2502;   &#x2514; 0
           &#x2514; 10

ZeroDivisionError: division by zero
&#x6355;&#x6349;&#x5230;&#x9664;&#x96F6;&#x7570;&#x5E38;</code></pre><p><strong><code>onerror</code> &#x81EA;&#x5B9A;&#x7FA9;&#x932F;&#x8AA4;&#x8655;&#x7406;</strong></p><p>&#x9084;&#x53EF;&#x4EE5;&#x4F7F;&#x7528; <code>onerror</code> &#x53C3;&#x6578;&#x4F86;&#x8A2D;&#x7F6E;&#x4E00;&#x500B;&#x56DE;&#x8ABF;&#x51FD;&#x6578;&#xFF0C;&#x5728;&#x6355;&#x6349;&#x5230;&#x7570;&#x5E38;&#x6642;&#x57F7;&#x884C;&#x81EA;&#x5B9A;&#x7FA9;&#x7684;&#x908F;&#x8F2F;&#xFF0C;&#x4F8B;&#x5982;&#x767C;&#x9001;&#x901A;&#x77E5;&#x6216;&#x8A18;&#x9304;&#x984D;&#x5916;&#x4FE1;&#x606F;:</p><pre><code class="language-python">from loguru import logger

def notify_admin(e):
    print(f&quot;&#x7CFB;&#x7D71;&#x51FA;&#x932F;&#xFF1A;{e}&quot;)
    print(&quot;&#x555F;&#x52D5;&#x7DCA;&#x6025;&#x61C9;&#x8B8A;&#x6D41;&#x7A0B;&#x3001;&#x6536;&#x96C6;&#x6545;&#x969C;&#x6392;&#x9664;&#x6578;&#x64DA;&#x3001;&#x767C;&#x9001;&#x90F5;&#x4EF6;...&quot;)

@logger.catch(onerror=notify_admin)
def main():
    10 / 0  # &#x6545;&#x610F;&#x5F15;&#x767C;&#x932F;&#x8AA4;

main()</code></pre><p>&#x7576;&#x9019;&#x6BB5;&#x7A0B;&#x5F0F;&#x57F7;&#x884C;&#x6642;&#xFF0C;<code>notify_admin()</code>&#x6703;&#x88AB;&#x8ABF;&#x7528;&#xFF0C;&#x4E26;&#x5C07;&#x6355;&#x6349;&#x5230;&#x7684;&#x7570;&#x5E38;&#x8CC7;&#x8A0A;&#x50B3;&#x905E;&#x7D66;&#x5B83;&#x3002;</p><pre><code class="language-bash">2024-09-28 14:21:33.986 | ERROR    | __main__:&lt;module&gt;:11 - An error has been caught in function &apos;&lt;module&gt;&apos;, process &apos;MainProcess&apos; (10861), thread &apos;MainThread&apos; (137755256123392):
Traceback (most recent call last):

&gt; File &quot;/content/main.py&quot;, line 11, in &lt;module&gt;
    main()
    &#x2514; &lt;function main at 0x7d49a2cb5fc0&gt;

  File &quot;/content/main.py&quot;, line 9, in main
    10 / 0  # &#x6545;&#x610F;&#x5F15;&#x767C;&#x932F;&#x8AA4;

ZeroDivisionError: division by zero
&#x7CFB;&#x7D71;&#x51FA;&#x932F;&#xFF1A;division by zero
&#x555F;&#x52D5;&#x7DCA;&#x6025;&#x61C9;&#x8B8A;&#x6D41;&#x7A0B;&#x3001;&#x6536;&#x96C6;&#x6545;&#x969C;&#x6392;&#x9664;&#x6578;&#x64DA;&#x3001;&#x767C;&#x9001;&#x90F5;&#x4EF6;...</code></pre><p><strong>&#x6355;&#x6349;&#x7279;&#x5B9A;&#x7570;&#x5E38;</strong></p><p><code>logger.catch()</code> &#x9ED8;&#x8A8D;&#x6703;&#x6355;&#x6349;&#x6240;&#x6709;&#x985E;&#x578B;&#x7684;&#x7570;&#x5E38;&#xFF0C;&#x4F46;&#x4E5F;&#x53EF;&#x4EE5;&#x6839;&#x64DA;&#x9700;&#x6C42;&#x9078;&#x64C7;&#x6027;&#x5730;&#x6355;&#x6349;&#x7279;&#x5B9A;&#x985E;&#x578B;&#x7684;&#x7570;&#x5E38;&#xFF0C;&#x4F8B;&#x5982;&#x6307;&#x5B9A;&#x53EA;&#x6355;&#x6349;<code>Exception</code>&#x985E;&#x578B;&#x7684;&#x7570;&#x5E38;&#xFF0C;&#x9019;&#x6DB5;&#x84CB;&#x4E86;&#x5927;&#x591A;&#x6578;&#x6A19;&#x6E96;&#x7684;&#x7570;&#x5E38;&#x985E;&#x578B;:</p><pre><code class="language-python">from loguru import logger

@logger.catch(Exception)
def divide(a, b):
    return a / b

divide(10, 0)</code></pre><p>&#x4E5F;&#x53EF;&#x4EE5;&#x6355;&#x6349;&#x67D0;&#x4E9B;&#x7279;&#x5B9A;&#x7684;&#x7570;&#x5E38;&#x985E;&#x578B;&#xFF0C;&#x4F8B;&#x5982;<code>ZeroDivisionError</code>:</p><pre><code class="language-python">@logger.catch(ZeroDivisionError)
def divide(a, b):
    return a / b</code></pre><h2 id="%E7%B5%90%E8%AB%96">&#x7D50;&#x8AD6;</h2><p>Loguru&#x662F;&#x4E00;&#x500B;&#x7C21;&#x6F54;&#x4E14;&#x529F;&#x80FD;&#x8C50;&#x5BCC;&#x7684;&#x65E5;&#x8A8C;&#x5DE5;&#x5177;&#xFF0C;&#x80FD;&#x6709;&#x6548;&#x63D0;&#x5347;&#x958B;&#x767C;&#x904E;&#x7A0B;&#x4E2D;&#x7684;&#x932F;&#x8AA4;&#x6392;&#x67E5;&#x548C;&#x6027;&#x80FD;&#x512A;&#x5316;&#x3002;&#x8207;&#x6A19;&#x6E96;&#x7684;Python logging&#x76F8;&#x6BD4;&#xFF0C;Loguru &#x66F4;&#x52A0;&#x76F4;&#x89C0;&#x6613;&#x7528;&#xFF0C;&#x7121;&#x9700;&#x7E41;&#x7463;&#x7684;&#x914D;&#x7F6E;&#xFF0C;&#x5373;&#x53EF;&#x8F15;&#x9B06;&#x4E0A;&#x624B;&#x3002;&#x6B64;&#x5916;&#xFF0C;&#x5B83;&#x63D0;&#x4F9B;&#x4E86;&#x9748;&#x6D3B;&#x7684;&#x81EA;&#x8A02;&#x683C;&#x5F0F;&#x3001;&#x81EA;&#x52D5;&#x6A94;&#x6848;&#x8F2A;&#x66FF;&#x3001;&#x58D3;&#x7E2E;&#x548C;&#x65E5;&#x8A8C;&#x4FDD;&#x7559;&#x7B49;&#x529F;&#x80FD;&#xFF0C;&#x9019;&#x4E9B;&#x7279;&#x6027;&#x5C0D;&#x65BC;&#x9700;&#x8981;&#x9577;&#x671F;&#x904B;&#x884C;&#x4E14;&#x5C0D;&#x65E5;&#x8A8C;&#x7BA1;&#x7406;&#x8981;&#x6C42;&#x9AD8;&#x7684;&#x61C9;&#x7528;&#x5C24;&#x5176;&#x6709;&#x7528;&#x3002;</p><p>Loguru&#x7684;<code>logger.catch()</code>&#x9032;&#x4E00;&#x6B65;&#x7C21;&#x5316;&#x4E86;&#x932F;&#x8AA4;&#x8655;&#x7406;&#x6D41;&#x7A0B;&#x514D;&#x65BC;&#x624B;&#x52D5;&#x7DE8;&#x5BEB;&#x5927;&#x91CF; <code>try-except</code>&#xFF0C;&#x5141;&#x8A31;&#x958B;&#x767C;&#x8005;&#x65B9;&#x4FBF;&#x5730;&#x6355;&#x6349;&#x7570;&#x5E38;&#x4E26;&#x8A18;&#x9304;&#x8A73;&#x7D30;&#x7684;&#x5806;&#x758A;&#x4FE1;&#x606F;&#xFF0C;&#x5F9E;&#x800C;&#x63D0;&#x5347;&#x65E5;&#x8A8C;&#x7684;&#x53EF;&#x8B80;&#x6027;&#x548C;&#x61C9;&#x7528;&#x7684;&#x53EF;&#x7DAD;&#x8B77;&#x6027;&#xFF0C;&#x5927;&#x5E45;&#x63D0;&#x5347;&#x4E86;&#x932F;&#x8AA4;&#x6392;&#x67E5;&#x7684;&#x6548;&#x7387;&#x3002;&#x3002;</p>]]></content:encoded></item><item><title><![CDATA[unRAID Server Note 03]]></title><description><![CDATA[<h1 id="unraidflexible-powerful-home-server-plugins%E7%AF%87-%E4%B8%8B">unRAID - Flexible &amp; Powerful Home Server Plugins&#x7BC7; (&#x4E0B;)</h1>
<p>&#x5728;&#x4E0A;&#x4E00;&#x7BC7;&#x6587;&#x7AE0;&#x4E2D;&#xFF0C;&#x6211;&#x5011;&#x4ECB;&#x7D39;&#x4E86;&#x5E7E;&#x6B3E;&#x5FC5;&#x5099;&#x7684;unRAID&#x63D2;&#x4EF6;&#xFF0C;&#x63D0;&#x5347;&#x4E86;&#x7CFB;&#x7D71;&#x7684;&#x6027;&#x80FD;&#x548C;&#x7BA1;&#x7406;&#x6548;&#x7387;&#x3002;&#x63A5;&#x4E0B;&#x4F86;&#xFF0C;</p>]]></description><link>https://ghost.augustushsu.com/unraid-server-note-03/</link><guid isPermaLink="false">66f1a4dcbd8ad405433c3b32</guid><category><![CDATA[Unraid-Server-Note]]></category><dc:creator><![CDATA[AugustusHsu]]></dc:creator><pubDate>Sun, 20 Oct 2024 12:00:45 GMT</pubDate><media:content url="https://ghost.augustushsu.com/content/images/2024/09/unraid-server-note-03.png" medium="image"/><content:encoded><![CDATA[<h1 id="unraidflexible-powerful-home-server-plugins%E7%AF%87-%E4%B8%8B">unRAID - Flexible &amp; Powerful Home Server Plugins&#x7BC7; (&#x4E0B;)</h1>
<img src="https://ghost.augustushsu.com/content/images/2024/09/unraid-server-note-03.png" alt="unRAID Server Note 03"><p>&#x5728;&#x4E0A;&#x4E00;&#x7BC7;&#x6587;&#x7AE0;&#x4E2D;&#xFF0C;&#x6211;&#x5011;&#x4ECB;&#x7D39;&#x4E86;&#x5E7E;&#x6B3E;&#x5FC5;&#x5099;&#x7684;unRAID&#x63D2;&#x4EF6;&#xFF0C;&#x63D0;&#x5347;&#x4E86;&#x7CFB;&#x7D71;&#x7684;&#x6027;&#x80FD;&#x548C;&#x7BA1;&#x7406;&#x6548;&#x7387;&#x3002;&#x63A5;&#x4E0B;&#x4F86;&#xFF0C;&#x8B93;&#x6211;&#x5011;&#x7E7C;&#x7E8C;&#x63A2;&#x7D22;&#x66F4;&#x591A;&#x5BE6;&#x7528;&#x7684;&#x5DE5;&#x5177;&#xFF0C;&#x5982;Compose Manager&#x3001;Disk Location&#x3001;FolderView&#x7B49;&#xFF0C;&#x9019;&#x4E9B;&#x63D2;&#x4EF6;&#x80FD;&#x9032;&#x4E00;&#x6B65;&#x5F37;&#x5316;&#x60A8;&#x7684;unRAID&#x7CFB;&#x7D71;&#xFF0C;&#x8B93;&#x65E5;&#x5E38;&#x7BA1;&#x7406;&#x8B8A;&#x5F97;&#x66F4;&#x52A0;&#x8F15;&#x9B06;&#x548C;&#x9AD8;&#x6548;&#x3002;</p>
<h2 id="docker-compose-manager"><strong>Docker Compose Manager</strong></h2>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-45.png" class="kg-image" alt="unRAID Server Note 03" loading="lazy" width="436" height="302"></figure>
<p>Docker Compose Manager&#x80FD;&#x8B93;&#x4F7F;&#x7528;&#x8005;&#x80FD;&#x5920;&#x65B9;&#x4FBF;&#x5730;&#x7BA1;&#x7406;&#x548C;&#x904B;&#x884C;&#x57FA;&#x65BC;Docker Compose&#x7684;&#x61C9;&#x7528;&#x7A0B;&#x5F0F;&#xFF0C;&#x53EF;&#x4EE5;&#x914D;&#x7F6E;<code>docker-compose.yml</code>&#x548C;&#x5C0D;&#x61C9;&#x7684;<code>.env</code>&#x6A94;&#x3002;&#x9019;&#x500B;Plugin&#x63D0;&#x4F9B;&#x4E86;&#x5716;&#x5F62;&#x5316;&#x7684;&#x7BA1;&#x7406;&#x754C;&#x9762;&#xFF0C;&#x53EF;&#x4EE5;&#x8F15;&#x9B06;&#x67E5;&#x770B;&#x3001;&#x904B;&#x884C;&#x548C;&#x505C;&#x6B62;Docker Compose&#x5B9A;&#x7FA9;&#x7684;&#x61C9;&#x7528;&#x7A0B;&#x5F0F;&#xFF0C;&#x9664;&#x6B64;&#x4E4B;&#x5916;&#xFF0C;&#x4E5F;&#x652F;&#x6301;&#x81EA;&#x52D5;&#x91CD;&#x555F;&#x548C;&#x66F4;&#x65B0;&#x61C9;&#x7528;&#x7A0B;&#x5F0F;&#xFF0C;&#x78BA;&#x4FDD;&#x60A8;&#x7684;&#x591A;&#x5BB9;&#x5668;&#x61C9;&#x7528;&#x59CB;&#x7D42;&#x8655;&#x65BC;&#x6700;&#x4F73;&#x72C0;&#x614B;&#xFF0C;&#x9084;&#x53EF;&#x4EE5;&#x901A;&#x904E;&#x8A72;Plugin&#x76F4;&#x63A5;&#x67E5;&#x770B;&#x6BCF;&#x500B;Docker&#x5BB9;&#x5668;&#x7684;&#x904B;&#x884C;&#x65E5;&#x8A8C;&#xFF0C;&#x65B9;&#x4FBF;&#x5FEB;&#x901F;&#x8A3A;&#x65B7;&#x554F;&#x984C;</p>
<p>&#x5B89;&#x88DD;&#x5B8C;&#x5F8C;&#x53EF;&#x4EE5;&#x5728;&#x300C;SETTINGS&#x300D;&gt;&#x300C;Compose&#x300D;&#x4E2D;&#x8A2D;&#x5B9A;: </p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-46.png" class="kg-image" alt="unRAID Server Note 03" loading="lazy" width="1010" height="292" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-46.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2024/09/image-46.png 1000w, https://ghost.augustushsu.com/content/images/2024/09/image-46.png 1010w" sizes="(min-width: 720px) 720px"></figure>
<p>&#x5728;&#x300C;SETTINGS&#x300D;&gt;&#x300C;Compose Manager&#x300D;&#x53EF;&#x4EE5;&#x958B;&#x59CB;&#x914D;&#x7F6E;<code>docker-compose.yml</code>&#xFF0C;&#x5982;&#x679C;&#x6709;&#x958B;<strong>Show Compose in Header Menu</strong>&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x9EDE;&#x9078;&#x4E0A;&#x65B9;&#x7684;&#x300C;COMPOSE&#x300D;&#x9032;&#x5230;&#x914D;&#x7F6E;&#x756B;&#x9762;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-47.png" class="kg-image" alt="unRAID Server Note 03" loading="lazy" width="1388" height="218" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-47.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2024/09/image-47.png 1000w, https://ghost.augustushsu.com/content/images/2024/09/image-47.png 1388w" sizes="(min-width: 720px) 720px"></figure>
<p>&#x9EDE;&#x9078;&#x300C;ADD NEW STACK&#x300D;&#x53EF;&#x4EE5;&#x958B;&#x59CB;&#x5275;&#x5EFA;Docker Compose:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-48.png" class="kg-image" alt="unRAID Server Note 03" loading="lazy" width="521" height="484"></figure>
<p>&#x5275;&#x5EFA;&#x5B8C;&#x5F8C;&#x53EF;&#x4EE5;&#x9EDE;&#x5DE6;&#x908A;&#x7684;&#x9F52;&#x8F2A;&#x518D;&#x9EDE;&#x300C;EDIT STACK&#x300D;&#x958B;&#x59CB;&#x914D;&#x7F6E;&#x6240;&#x9700;&#x7684;COMPOSE FILE&#x548C;ENV FILE:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-52.png" class="kg-image" alt="unRAID Server Note 03" loading="lazy" width="1215" height="679" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-52.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2024/09/image-52.png 1000w, https://ghost.augustushsu.com/content/images/2024/09/image-52.png 1215w" sizes="(min-width: 720px) 720px"></figure>
<p>&#x914D;&#x7F6E;&#x5B8C;&#x9EDE;&#x9078;&#x300C;COMPOSE UP&#x300D;&#x6703;&#x5728;&#x300C;DOCKER&#x300D;&#x4E0A;&#x770B;&#x5230;&#x555F;&#x52D5;&#x7684;container&#xFF0C;&#x5F8C;&#x7E8C;&#x53EF;&#x4EE5;&#x9760;FolderView&#x4F86;&#x5C07;&#x9019;&#x4E9B;container&#x6574;&#x5408;&#x8D77;&#x4F86;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-53.png" class="kg-image" alt="unRAID Server Note 03" loading="lazy" width="234" height="215"></figure>
<h2 id="folderview">FolderView</h2>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-54.png" class="kg-image" alt="unRAID Server Note 03" loading="lazy" width="437" height="301"></figure>
<p>FolderView&#x4F9B;&#x4E86;&#x4E00;&#x4E9B;&#x91DD;&#x5C0D;Docker Container&#x8996;&#x89BA;&#x5316;&#x7BA1;&#x7406;&#x7684;&#x5BE6;&#x7528;&#x529F;&#x80FD;&#xFF0C;&#x53EF;&#x4EE5;&#x5C07;&#x591A;&#x500B; Docker &#x5BB9;&#x5668;&#x647A;&#x758A;&#x6210;&#x4E00;&#x500B;&#x5716;&#x793A;&#xFF0C;&#x8B93;unRAID&#x7684;Docker&#x7BA1;&#x7406;&#x754C;&#x9762;&#x66F4;&#x52A0;&#x7C21;&#x6F54;&#x907F;&#x514D;&#x754C;&#x9762;&#x8B8A;&#x5F97;&#x904E;&#x65BC;&#x96DC;&#x4E82;&#xFF0C;&#x7279;&#x5225;&#x9069;&#x5408;&#x6709;&#x5927;&#x91CF;&#x5BB9;&#x5668;&#x904B;&#x884C;&#x7684;&#x5834;&#x666F;&#x3002;</p>
<p>&#x5728;&#x300C;DOCKER&#x300D;&gt;&#x300C;ADD FOLDER&#x300D;&#x5F80;&#x4E0B;&#x6ED1;&#x5C31;&#x53EF;&#x4EE5;&#x958B;&#x59CB;&#x8A2D;&#x5B9A;&#x8981;&#x6574;&#x5408;&#x8D77;&#x4F86;&#x7684;container:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-59.png" class="kg-image" alt="unRAID Server Note 03" loading="lazy" width="937" height="404" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-59.png 600w, https://ghost.augustushsu.com/content/images/2024/09/image-59.png 937w" sizes="(min-width: 720px) 720px"></figure>
<p>&#x9084;&#x63D0;&#x4F9B;&#x4E86;&#x81EA;&#x8A02;Docker&#x5BB9;&#x5668;Logo&#x7684;&#x529F;&#x80FD;&#xFF0C;&#x8F38;&#x5165;Icon&#x7684;&#x7DB2;&#x5740;&#xFF0C;&#x5373;&#x53EF;&#x70BA;&#x647A;&#x758A;&#x8CC7;&#x6599;&#x593E;&#x8A2D;&#x5B9A;&#x500B;&#x6027;&#x5316;&#x7684;&#x5716;&#x793A;&#xFF0C;&#x6709;&#x52A9;&#x65BC;&#x5FEB;&#x901F;&#x8B58;&#x5225;&#x5404;&#x500B;&#x5BB9;&#x5668;&#xFF0C;&#x8B93;&#x754C;&#x9762;&#x8B8A;&#x5F97;&#x66F4;&#x52A0;&#x7F8E;&#x89C0;&#x548C;&#x5C08;&#x696D;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-57.png" class="kg-image" alt="unRAID Server Note 03" loading="lazy" width="872" height="132" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-57.png 600w, https://ghost.augustushsu.com/content/images/2024/09/image-57.png 872w" sizes="(min-width: 720px) 720px"></figure>
<p>&#x6298;&#x758A;&#x5F8C;&#x53EF;&#x4EE5;&#x8B93;&#x9801;&#x9762;&#x66F4;&#x7C21;&#x6F54;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-55.png" class="kg-image" alt="unRAID Server Note 03" loading="lazy" width="1489" height="174" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-55.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2024/09/image-55.png 1000w, https://ghost.augustushsu.com/content/images/2024/09/image-55.png 1489w" sizes="(min-width: 720px) 720px"></figure>
<p>&#x647A;&#x758A;&#x5F8C;&#x7684;&#x5716;&#x793A;&#x53EF;&#x4EE5;&#x5C55;&#x958B;&#xFF0C;&#x986F;&#x793A;&#x6240;&#x6709;&#x904B;&#x884C;&#x4E2D;&#x7684;&#x5BB9;&#x5668;&#x548C;&#x5176;&#x8A73;&#x7D30;&#x72C0;&#x614B;&#xFF0C;&#x4F7F;&#x7528;&#x8005;&#x53EA;&#x9700;&#x9EDE;&#x64CA;&#x5373;&#x53EF;&#x6AA2;&#x8996;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-58.png" class="kg-image" alt="unRAID Server Note 03" loading="lazy" width="1593" height="799" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-58.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2024/09/image-58.png 1000w, https://ghost.augustushsu.com/content/images/2024/09/image-58.png 1593w" sizes="(min-width: 720px) 720px"></figure>
<h2 id="disk-location"><strong>Disk Location</strong></h2>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-60.png" class="kg-image" alt="unRAID Server Note 03" loading="lazy" width="435" height="297"></figure>
<p>Disk Location&#x76EE;&#x7684;&#x662F;&#x5E6B;&#x52A9;&#x7528;&#x6236;&#x66F4;&#x597D;&#x5730;&#x7BA1;&#x7406;&#x7269;&#x7406;&#x786C;&#x789F;&#x7684;&#x4F4D;&#x7F6E;&#x4FE1;&#x606F;&#xFF0C;&#x5C0D;&#x65BC;&#x4F7F;&#x7528;&#x591A;&#x9846;&#x786C;&#x789F;&#x7684;&#x4F3A;&#x670D;&#x5668;&#xFF0C;&#x7528;&#x6236;&#x53EF;&#x80FD;&#x6703;&#x9047;&#x5230;&#x56F0;&#x96E3;&#xFF0C;&#x5C24;&#x5176;&#x5728;&#x9700;&#x8981;&#x8B58;&#x5225;&#x3001;&#x66FF;&#x63DB;&#x6216;&#x7DAD;&#x8B77;&#x786C;&#x789F;&#x6642;&#xFF0C;&#x96E3;&#x4EE5;&#x8FC5;&#x901F;&#x5224;&#x65B7;&#x54EA;&#x4E00;&#x9846;&#x786C;&#x789F;&#x4F4D;&#x65BC;&#x54EA;&#x500B;&#x5BE6;&#x9AD4;&#x69FD;&#x4F4D;&#x3002;Disk Location&#x63D0;&#x4F9B;&#x4E86;&#x4E00;&#x500B;&#x76F4;&#x89C0;&#x7684;&#x5716;&#x5F62;&#x5316;&#x754C;&#x9762;&#xFF0C;&#x80FD;&#x8F15;&#x9B06;&#x8A18;&#x9304;&#x548C;&#x8FFD;&#x8E64;&#x786C;&#x789F;&#x7684;&#x7269;&#x7406;&#x4F4D;&#x7F6E;&#xFF0C;&#x5F9E;&#x800C;&#x63D0;&#x9AD8;&#x7CFB;&#x7D71;&#x7BA1;&#x7406;&#x6548;&#x7387;&#x3002;</p>
<p>&#x5F9E;&#x300C;PLUGINS&#x300D;&gt;&#x300C;Disk Location&#x300D;&#x53EF;&#x4EE5;&#x9032;&#x5230;&#x7BA1;&#x7406;&#x7684;&#x9801;&#x9762;&#xFF0C;&#x5176;&#x4E2D;&#x9EDE;&#x9078;&#x300C;System&#x300D;&#x53EF;&#x4EE5;&#x958B;&#x59CB;&#x6383;&#x63CF;&#x786C;&#x789F;&#xFF0C;&#x5982;&#x679C;&#x662F;&#x7B2C;&#x4E00;&#x6B21;&#x6309;&#x9215;&#x61C9;&#x8A72;&#x53EA;&#x6703;&#x6709;&#x300C;FORCE SCAN ALL&#x300D;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-62.png" class="kg-image" alt="unRAID Server Note 03" loading="lazy" width="1078" height="245" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-62.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2024/09/image-62.png 1000w, https://ghost.augustushsu.com/content/images/2024/09/image-62.png 1078w" sizes="(min-width: 720px) 720px"></figure>
<p>&#x6383;&#x63CF;&#x5F8C;&#x53EF;&#x4EE5;&#x9032;&#x5230;&#x300C;Configuration&#x300D;&#x8ABF;&#x6574;&#x8A2D;&#x5B9A;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-61.png" class="kg-image" alt="unRAID Server Note 03" loading="lazy" width="750" height="560" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-61.png 600w, https://ghost.augustushsu.com/content/images/2024/09/image-61.png 750w" sizes="(min-width: 720px) 720px"></figure>
<p>&#x5728;&#x300C;Configuration&#x300D;&#x6700;&#x4E0B;&#x65B9;&#x9EDE;&#x9078;&#x300C;+&#x300D;&#x7684;&#x5716;&#x793A;&#x53EF;&#x4EE5;&#x65B0;&#x589E;&#x300C;Disk Tray Layout&#x300D;&#x7684;&#x683C;&#x5F0F;&#xFF0C;&#x9019;&#x500B;&#x683C;&#x5F0F;&#x53D6;&#x6C7A;&#x65BC;&#x5B58;&#x653E;&#x786C;&#x789F;&#x7684;&#x5F62;&#x5F0F;&#xFF0C;&#x6211;&#x6240;&#x4F7F;&#x7528;&#x7684;&#x662F;8&#x683C;&#x786C;&#x789F;&#x6AC3;&#x8A2D;&#x5B9A;&#x5982;&#x4E0B;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-63.png" class="kg-image" alt="unRAID Server Note 03" loading="lazy" width="395" height="902"></figure>
<p>&#x5275;&#x5EFA;&#x5B8C;Group&#x53EF;&#x4EE5;&#x9032;&#x5230;&#x300C;Tray Allocations&#x300D;&#x8A2D;&#x5B9A;&#x8981;&#x52A0;&#x5165;&#x524D;&#x9762;Layout&#x7684;&#x786C;&#x789F;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-66.png" class="kg-image" alt="unRAID Server Note 03" loading="lazy" width="1243" height="427" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-66.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2024/09/image-66.png 1000w, https://ghost.augustushsu.com/content/images/2024/09/image-66.png 1243w" sizes="(min-width: 720px) 720px"></figure>
<p>&#x5982;&#x679C;&#x786C;&#x789F;&#x6240;&#x5728;&#x7684;&#x786C;&#x789F;&#x6AC3;&#x6709;&#x71C8;&#x865F;&#x7684;&#x986F;&#x793A;&#xFF0C;&#x53EF;&#x4EE5;&#x9EDE;&#x9078;&#x300C;LOCATE&#x300D;&#x627E;&#x5230;&#x9078;&#x53D6;&#x7684;&#x786C;&#x789F;&#x5177;&#x9AD4;&#x5728;&#x786C;&#x789F;&#x6AC3;&#x6240;&#x8655;&#x7684;&#x4F4D;&#x7F6E;&#xFF0C;Group&#x53EF;&#x4EE5;&#x9078;&#x53D6;&#x524D;&#x9762;&#x6240;&#x5275;&#x5EFA;&#x7684;Layout&#xFF0C;TrayID&#x5247;&#x662F;&#x8A2D;&#x5B9A;&#x6240;&#x9078;&#x786C;&#x789F;&#x6240;&#x5728;&#x7684;&#x4F4D;&#x7F6E;&#xFF0C;&#x8A2D;&#x5B9A;&#x5B8C;&#x6210;&#x9EDE;&#x9078;&#x300C;SAVE&#x300D;&#x5373;&#x53EF;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-67.png" class="kg-image" alt="unRAID Server Note 03" loading="lazy" width="1222" height="645" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-67.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2024/09/image-67.png 1000w, https://ghost.augustushsu.com/content/images/2024/09/image-67.png 1222w" sizes="(min-width: 720px) 720px"></figure>
<p>&#x524D;&#x9762;&#x7684;&#x8A2D;&#x5B9A;&#x5B8C;&#x6210;&#x5F8C;&#x5373;&#x53EF;&#x5728;&#x300C;DASHBOARD&#x300D;&#x4E0A;&#x770B;&#x5230;&#x591A;&#x4E86;&#x300C;Disk Location&#x300D;&#x7684;&#x6B04;&#x4F4D;&#xFF0C;&#x7576;&#x786C;&#x789F;&#x51FA;&#x554F;&#x984C;&#x53EF;&#x4EE5;&#x5FEB;&#x901F;&#x7684;&#x5B9A;&#x4F4D;&#x5230;&#x786C;&#x789F;&#x6240;&#x5728;&#x7684;&#x4F4D;&#x7F6E;&#x9032;&#x884C;&#x66FF;&#x63DB;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-69.png" class="kg-image" alt="unRAID Server Note 03" loading="lazy" width="154" height="310"></figure>
<p>&#x4EE5;&#x4E0A;&#x662F;&#x7C97;&#x7565;&#x7684;&#x4F7F;&#x7528;Disk Location&#x7684;&#x65B9;&#x6CD5;&#xFF0C;&#x5982;&#x679C;&#x4E86;&#x89E3;&#x8A2D;&#x5B9A;&#x88E1;&#x7684;&#x9078;&#x9805;&#x9084;&#x53EF;&#x4EE5;&#x505A;&#x66F4;&#x7D30;&#x7DFB;&#x7684;&#x8ABF;&#x6574;&#x3002;</p>
<h2 id="dynamix-system-temperature"><strong>Dynamix System Temperature</strong></h2>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-72.png" class="kg-image" alt="unRAID Server Note 03" loading="lazy" width="437" height="302"></figure>
<p>Dynamix System Temperature&#x7528;&#x65BC;&#x76E3;&#x63A7;&#x4F3A;&#x670D;&#x5668;&#x7684;&#x786C;&#x9AD4;&#x6EAB;&#x5EA6;&#xFF0C;&#x7279;&#x5225;&#x662F; CPU &#x548C;&#x4E3B;&#x6A5F;&#x677F;&#x7684;&#x6EAB;&#x5EA6;&#xFF0C;&#x5B89;&#x88DD;&#x5B8C;&#x5F8C;&#x53EF;&#x4EE5;&#x5F9E;&#x300C;SETTINGS&#x300D;&gt;&#x300C;System Temp&#x300D;&#x9032;&#x5165;&#x5230;&#x8A2D;&#x5B9A;&#x756B;&#x9762;&#xFF0C;&#x9078;&#x64C7;&#x8981;&#x76E3;&#x63A7;&#x7684;&#x6EAB;&#x5EA6;&#x5373;&#x53EF;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-73.png" class="kg-image" alt="unRAID Server Note 03" loading="lazy" width="1044" height="389" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-73.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2024/09/image-73.png 1000w, https://ghost.augustushsu.com/content/images/2024/09/image-73.png 1044w" sizes="(min-width: 720px) 720px"></figure>
<p>&#x8A2D;&#x5B9A;&#x5B8C;&#x5F8C;&#x53EF;&#x4EE5;&#x5728;&#x300C;DASHBORAD&#x300D;&#x7684;MOTHERBOARD&#x548C;PROCESSOR&#x4E2D;&#x770B;&#x5230;&#x76E3;&#x63A7;&#x7684;&#x6EAB;&#x5EA6;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-71.png" class="kg-image" alt="unRAID Server Note 03" loading="lazy" width="914" height="540" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-71.png 600w, https://ghost.augustushsu.com/content/images/2024/09/image-71.png 914w" sizes="(min-width: 720px) 720px"></figure>
<h2 id="recycle-bin">Recycle Bin</h2>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-77.png" class="kg-image" alt="unRAID Server Note 03" loading="lazy" width="499" height="331"></figure>
<p>unRAID&#x7684;Recycle Bin&#x63D2;&#x4EF6;&#x70BA;&#x60A8;&#x7684;&#x7DB2;&#x7D61;&#x5171;&#x4EAB;&#x63D0;&#x4F9B;&#x4E86;&#x4E00;&#x500B;&#x56DE;&#x6536;&#x7AD9;&#x529F;&#x80FD;&#x3002;&#x7576;&#x60A8;&#x5728;&#x5171;&#x4EAB;&#x6587;&#x4EF6;&#x593E;&#x4E2D;&#x522A;&#x9664;&#x6587;&#x4EF6;&#x6642;&#xFF0C;&#x9019;&#x4E9B;&#x6587;&#x4EF6;&#x4E0D;&#x6703;&#x7ACB;&#x5373;&#x5F9E;&#x7CFB;&#x7D71;&#x4E2D;&#x6C38;&#x4E45;&#x522A;&#x9664;&#xFF0C;&#x800C;&#x662F;&#x88AB;&#x79FB;&#x52D5;&#x5230;&#x56DE;&#x6536;&#x7AD9;&#x4E2D;&#x3002;&#x9019;&#x6A23;&#x5C31;&#x53EF;&#x4EE5;&#x5728;&#x9700;&#x8981;&#x6642;&#x8F15;&#x9B06;&#x6062;&#x5FA9;&#x8AA4;&#x522A;&#x7684;&#x6587;&#x4EF6;&#xFF0C;&#x589E;&#x5F37;&#x6578;&#x64DA;&#x7684;&#x5B89;&#x5168;&#x6027;&#x548C;&#x53EF;&#x9760;&#x6027;&#x3002;</p>
<p>&#x901A;&#x904E;unRAID&#x7684;&#x7DB2;&#x9801;&#x7BA1;&#x7406;&#x754C;&#x9762;&#xFF0C;&#x53EF;&#x4EE5;&#x8A2D;&#x5B9A;&#x54EA;&#x4E9B;&#x5171;&#x4EAB;&#x6587;&#x4EF6;&#x593E;&#x555F;&#x7528;&#x56DE;&#x6536;&#x7AD9;&#x529F;&#x80FD;&#xFF0C;&#x4E26;&#x8A2D;&#x7F6E;&#x81EA;&#x52D5;&#x6E05;&#x7406;&#x898F;&#x5247;&#xFF0C;&#x5982;&#x5728;&#x56DE;&#x6536;&#x7AD9;&#x4E2D;&#x4FDD;&#x7559;&#x6587;&#x4EF6;&#x7684;&#x5929;&#x6578;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x67E5;&#x770B;&#x3001;&#x6062;&#x5FA9;&#x6216;&#x6C38;&#x4E45;&#x522A;&#x9664;&#x56DE;&#x6536;&#x7AD9;&#x4E2D;&#x7684;&#x6587;&#x4EF6;&#x3002;</p>
<p>&#x53EF;&#x4EE5;&#x5728;&#x300C;SETTINGS&#x300D;&gt;&#x300C;Recycle Bin&#x300D;&#x4E2D;&#x67E5;&#x770B;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-29.png" class="kg-image" alt="unRAID Server Note 03" loading="lazy" width="1351" height="839" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-29.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2024/09/image-29.png 1000w, https://ghost.augustushsu.com/content/images/2024/09/image-29.png 1351w" sizes="(min-width: 720px) 720px"></figure>
<p>&#x7576;&#x5728;&#x6307;&#x5B9A;&#x7684;&#x5171;&#x4EAB;&#x6587;&#x4EF6;&#x593E;&#x4E2D;&#x522A;&#x9664;&#x6587;&#x4EF6;&#x6642;&#xFF0C;&#x6587;&#x4EF6;&#x5C07;&#x88AB;&#x79FB;&#x52D5;&#x5230;&#x56DE;&#x6536;&#x7AD9;&#xFF0C;&#x5982;&#x4E0B;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-30.png" class="kg-image" alt="unRAID Server Note 03" loading="lazy" width="1243" height="133" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-30.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2024/09/image-30.png 1000w, https://ghost.augustushsu.com/content/images/2024/09/image-30.png 1243w" sizes="(min-width: 720px) 720px"></figure>
<p>&#x8981;&#x6CE8;&#x610F;&#x7684;&#x662F;&#x56DE;&#x6536;&#x7AD9;&#x4E2D;&#x7684;&#x6587;&#x4EF6;&#x4ECD;&#x4F54;&#x7528;&#x78C1;&#x76E4;&#x7A7A;&#x9593;&#xFF0C;&#x8ACB;<strong>&#x5B9A;&#x671F;&#x6E05;&#x7406;</strong>&#x6216;<strong>&#x8A2D;&#x5B9A;&#x81EA;&#x52D5;&#x6E05;&#x7406;&#x7B56;&#x7565;</strong>&#xFF0C;&#x522A;&#x9664;&#x7684;&#x654F;&#x611F;&#x6587;&#x4EF6;&#x53EF;&#x80FD;&#x4ECD;&#x5B58;&#x5728;&#x65BC;&#x56DE;&#x6536;&#x7AD9;&#x4E2D;&#xFF0C;<strong>&#x5C0D;&#x91CD;&#x8981;&#x7684;&#x5171;&#x4EAB;&#x6587;&#x4EF6;&#x593E;&#x5EFA;&#x8B70;&#x8A2D;&#x7F6E;&#x8A2A;&#x554F;&#x6B0A;&#x9650;</strong>&#x3002;&#x9664;&#x6B64;&#x4E4B;&#x5916;&#x5728;<strong>&#x5927;&#x91CF;&#x6587;&#x4EF6;&#x64CD;&#x4F5C;&#x7684;&#x74B0;&#x5883;&#x4E0B;&#xFF0C;&#x56DE;&#x6536;&#x7AD9;&#x529F;&#x80FD;&#x53EF;&#x80FD;&#x5C0D;&#x7CFB;&#x7D71;&#x6027;&#x80FD;&#x6709;&#x8F15;&#x5FAE;&#x5F71;&#x97FF;</strong>&#xFF0C;&#x53EF;&#x6839;&#x64DA;&#x9700;&#x6C42;&#x8ABF;&#x6574;&#x8A2D;&#x7F6E;&#x3002;</p>
<h2 id="intel-gpu-top"><strong>Intel GPU TOP</strong></h2>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-74.png" class="kg-image" alt="unRAID Server Note 03" loading="lazy" width="497" height="339"></figure>
<p>Intel GPU TOP&#x5C08;&#x70BA;&#x652F;&#x6301; Intel &#x96C6;&#x6210;&#x986F;&#x793A;&#x5361;&#x7684;&#x7CFB;&#x7D71;&#x8A2D;&#x8A08;&#xFF0C;&#x53EF;&#x4EE5;&#x89E3;&#x9396;Intel GPU&#x7684;&#x786C;&#x4EF6;&#x52A0;&#x901F;&#x80FD;&#x529B;&#xFF0C;&#x8B93;unRAID&#x7528;&#x6236;&#x80FD;&#x5920;&#x5145;&#x5206;&#x5229;&#x7528;Intel GPU&#x4F86;&#x52A0;&#x901F;&#x5404;&#x7A2E;&#x591A;&#x5A92;&#x9AD4;&#x4EFB;&#x52D9;&#xFF0C;&#x4F8B;&#x5982;&#x8996;&#x983B;&#x8F49;&#x78BC;&#x3001;&#x8F49;&#x78BC;&#x89E3;&#x78BC;&#x3001;&#x5716;&#x50CF;&#x8655;&#x7406;&#x7B49;&#x3002;</p>
<p>&#x5B89;&#x88DD;&#x5B8C;&#x5F8C;&#x53EF;&#x4EE5;&#x5728;Docker&#x4E2D;&#x65B0;&#x589E;Device&#x8B8A;&#x6578;&#xFF0C;&#x8B93;Container&#x53EF;&#x4EE5;&#x4F7F;&#x7528;Intel GPU&#x7684;&#x786C;&#x4EF6;&#x52A0;&#x901F;&#x80FD;&#x529B;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-78.png" class="kg-image" alt="unRAID Server Note 03" loading="lazy" width="1001" height="414" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-78.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2024/09/image-78.png 1000w, https://ghost.augustushsu.com/content/images/2024/09/image-78.png 1001w" sizes="(min-width: 720px) 720px"></figure>
<h2 id="unassigned-devices">Unassigned Devices</h2>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-75.png" class="kg-image" alt="unRAID Server Note 03" loading="lazy" width="497" height="342"></figure>
<p>Unassigned Devices&#x53EF;&#x4EE5;&#x8B93;&#x7528;&#x6236;&#x5728;unRAID&#x4F3A;&#x670D;&#x5668;&#x4E2D;&#x639B;&#x8F09;&#x548C;&#x7BA1;&#x7406;&#x672A;&#x88AB;unRAID&#x9663;&#x5217;&#x6216;&#x5FEB;&#x53D6;&#x6C60;&#x4F7F;&#x7528;&#x7684;&#x786C;&#x789F;&#x6216;&#x5B58;&#x5132;&#x8A2D;&#x5099;&#xFF0C;&#x53EF;&#x4EE5;&#x9748;&#x6D3B;&#x5730;&#x8655;&#x7406;&#x5916;&#x90E8;&#x786C;&#x789F;&#x3001;USB&#x9A45;&#x52D5;&#x5668;&#x6216;&#x7DB2;&#x7D61;&#x5B58;&#x5132;&#x88DD;&#x7F6E;&#xFF0C;&#x4E26;&#x4E14;&#x4E0D;&#x9700;&#x8981;&#x5C07;&#x9019;&#x4E9B;&#x8A2D;&#x5099;&#x7D0D;&#x5165;unRAID&#x7684;&#x9663;&#x5217;&#x4E2D;&#xFF0C;&#x9019;&#x6B3E;&#x63D2;&#x4EF6;&#x5C0D;&#x65BC;&#x9700;&#x8981;&#x81E8;&#x6642;&#x6216;&#x5916;&#x90E8;&#x5B58;&#x5132;&#x7684;&#x4F7F;&#x7528;&#x60C5;&#x5883;&#x7279;&#x5225;&#x5BE6;&#x7528;&#x3002;</p>
<p>&#x5B89;&#x88DD;&#x5B8C;&#x5F8C;&#x5982;&#x679C;&#x6709;&#x672A;&#x52A0;&#x5165;&#x9663;&#x5217;&#x4E2D;&#x7684;&#x786C;&#x789F;&#xFF0C;&#x6703;&#x5728;&#x300C;MAIN&#x300D;&#x4E2D;&#x770B;&#x5230;Unassigned Devices&#x7684;&#x6B04;&#x4F4D;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-79.png" class="kg-image" alt="unRAID Server Note 03" loading="lazy" width="681" height="492" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-79.png 600w, https://ghost.augustushsu.com/content/images/2024/09/image-79.png 681w"></figure>
<p>&#x5982;&#x679C;Docker&#x6216;&#x662F;VM&#x6703;&#x9700;&#x8981;&#x4F7F;&#x7528;&#x5230;&#x9019;&#x4E9B;&#x786C;&#x789F;&#xFF0C;&#x53EF;&#x4EE5;&#x5C07;&#x9019;&#x4E9B;&#x786C;&#x789F;&#x76F4;&#x901A;&#x5230;&#x4F7F;&#x7528;&#x5834;&#x666F;&#x4E2D;&#x3002;</p>
<h2 id="unbalanced"><strong>unbalanced</strong></h2>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-76.png" class="kg-image" alt="unRAID Server Note 03" loading="lazy" width="496" height="309"></figure>
<p>Unbalance&#x5C08;&#x70BA;&#x91CD;&#x65B0;&#x5206;&#x4F48;&#x548C;&#x6574;&#x7406;&#x5B58;&#x5132;&#x6578;&#x64DA;&#x800C;&#x8A2D;&#x8A08;&#x3002;&#x5B83;&#x7684;&#x4E3B;&#x8981;&#x529F;&#x80FD;&#x662F;&#x5E6B;&#x52A9;&#x7528;&#x6236;&#x5C07;&#x6578;&#x64DA;&#x5F9E;&#x4E00;&#x9846;&#x6216;&#x591A;&#x9846;&#x786C;&#x789F;&#x4E0A;&#x79FB;&#x52D5;&#x5230;&#x5176;&#x4ED6;&#x786C;&#x789F;&#x4E0A;&#xFF0C;&#x4EE5;&#x5E73;&#x8861;&#x5B58;&#x5132;&#x7A7A;&#x9593;&#x7684;&#x4F7F;&#x7528;&#x3002;</p>
<p>&#x53EF;&#x4EE5;&#x5728;&#x300C;SETTINGS&#x300D;&gt;&#x300C;unbalanced&#x300D;&#x4E2D;&#x555F;&#x7528;&#x8A72;&#x529F;&#x80FD;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-81.png" class="kg-image" alt="unRAID Server Note 03" loading="lazy" width="912" height="280" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-81.png 600w, https://ghost.augustushsu.com/content/images/2024/09/image-81.png 912w" sizes="(min-width: 720px) 720px"></figure>
<p>&#x9EDE;&#x958B;&#x300C;Open Web UI&#x300D;&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x63D0;&#x4F9B;&#x5169;&#x7A2E;&#x4E3B;&#x8981;&#x64CD;&#x4F5C;&#x6A21;&#x5F0F;SCATTER&#x3001;GATHER:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-80.png" class="kg-image" alt="unRAID Server Note 03" loading="lazy" width="1678" height="651" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-80.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2024/09/image-80.png 1000w, https://ghost.augustushsu.com/content/images/size/w1600/2024/09/image-80.png 1600w, https://ghost.augustushsu.com/content/images/2024/09/image-80.png 1678w" sizes="(min-width: 720px) 720px"></figure>
<ol><li>SCATTER &#x7684;&#x4F5C;&#x7528;&#x662F;&#x5C07;&#x6307;&#x5B9A;&#x78C1;&#x789F;&#x4E0A;&#x7684;&#x6587;&#x4EF6;&#x5206;&#x6563;&#x5230;&#x5176;&#x4ED6;&#x672A;&#x6EFF;&#x7684;&#x78C1;&#x789F;&#x4E0A;&#x3002;&#x9019;&#x500B;&#x6A21;&#x5F0F;&#x975E;&#x5E38;&#x6709;&#x7528;&#xFF0C;&#x7576;&#x67D0;&#x500B;&#x78C1;&#x789F;&#x63A5;&#x8FD1;&#x5B58;&#x6EFF;&#x6642;&#xFF0C;&#x4F60;&#x53EF;&#x4EE5;&#x4F7F;&#x7528; SCATTER &#x628A;&#x6587;&#x4EF6;&#x79FB;&#x5230;&#x5176;&#x4ED6;&#x7A7A;&#x9593;&#x8F03;&#x591A;&#x7684;&#x78C1;&#x789F;&#xFF0C;&#x5F9E;&#x800C;&#x70BA;&#x8A72;&#x78C1;&#x789F;&#x91CB;&#x653E;&#x51FA;&#x7A7A;&#x9593;&#x3002;</li><li>GATHER &#x7684;&#x4F5C;&#x7528;&#x5247;&#x76F8;&#x53CD;&#xFF0C;&#x5B83;&#x662F;&#x5C07;&#x5206;&#x4F48;&#x5728;&#x591A;&#x500B;&#x78C1;&#x789F;&#x4E0A;&#x7684;&#x6587;&#x4EF6;&#x96C6;&#x4E2D;&#x5230;&#x6307;&#x5B9A;&#x7684;&#x4E00;&#x500B;&#x78C1;&#x789F;&#x4E0A;&#x3002;&#x7576;&#x7528;&#x6236;&#x5E0C;&#x671B;&#x6574;&#x7406;&#x6578;&#x64DA;&#xFF0C;&#x6216;&#x8005;&#x628A;&#x67D0;&#x500B;&#x8CC7;&#x6599;&#x593E;&#x4E0B;&#x7684;&#x6587;&#x4EF6;&#x90FD;&#x653E;&#x5230;&#x540C;&#x4E00;&#x500B;&#x78C1;&#x789F;&#x6642;&#xFF0C;GATHER &#x6A21;&#x5F0F;&#x975E;&#x5E38;&#x6709;&#x7528;&#x3002;</li></ol>
<p>&#x9019;&#x4E9B;&#x64CD;&#x4F5C;&#x4E0D;&#x6703;&#x6539;&#x8B8A;&#x6587;&#x4EF6;&#x7684;&#x76EE;&#x9304;&#x7D50;&#x69CB;&#xFF0C;&#x53EA;&#x662F;&#x6539;&#x8B8A;&#x5B83;&#x5011;&#x7684;&#x5B58;&#x5132;&#x4F4D;&#x7F6E;&#xFF0C;&#x5E6B;&#x52A9;&#x7528;&#x6236;&#x66F4;&#x597D;&#x5730;&#x7BA1;&#x7406;&#x4ED6;&#x5011;&#x7684;&#x5B58;&#x5132;&#x8CC7;&#x6E90;&#x3002;</p>]]></content:encoded></item><item><title><![CDATA[unRAID Server Note 02]]></title><description><![CDATA[<h1 id="unraidflexible-powerful-home-server-plugins%E7%AF%87-%E4%B8%8A">unRAID - Flexible &amp; Powerful Home Server Plugins&#x7BC7; (&#x4E0A;)</h1>
<p></p>
<p>unRAID&#x64C1;&#x6709;&#x8C50;&#x5BCC;&#x7684;&#x63D2;&#x4EF6;&#x751F;&#x614B;&#xFF0C;&#x4EE5;&#x4E0B;&#x662F;&#x6211;&#x8A8D;&#x70BA;&#x5FC5;&#x5099;&#x7684;&#x63D2;&#x4EF6;&#xFF0C;&#x5B83;&#x5011;&#x5927;&#x5927;&#x63D0;&#x5347;&#x4E86;&#x7CFB;&#x7D71;&#x7684;&#x529F;&#x80FD;&#x548C;&#x4F7F;&#x7528;&#x9AD4;&#x9A57;</p>]]></description><link>https://ghost.augustushsu.com/unraid-server-note-02/</link><guid isPermaLink="false">66f12221bd8ad405433c38dd</guid><category><![CDATA[Unraid-Server-Note]]></category><dc:creator><![CDATA[AugustusHsu]]></dc:creator><pubDate>Sun, 13 Oct 2024 12:00:09 GMT</pubDate><media:content url="https://ghost.augustushsu.com/content/images/2024/09/unraid-server-note-02.png" medium="image"/><content:encoded><![CDATA[<h1 id="unraidflexible-powerful-home-server-plugins%E7%AF%87-%E4%B8%8A">unRAID - Flexible &amp; Powerful Home Server Plugins&#x7BC7; (&#x4E0A;)</h1>
<img src="https://ghost.augustushsu.com/content/images/2024/09/unraid-server-note-02.png" alt="unRAID Server Note 02"><p></p>
<p>unRAID&#x64C1;&#x6709;&#x8C50;&#x5BCC;&#x7684;&#x63D2;&#x4EF6;&#x751F;&#x614B;&#xFF0C;&#x4EE5;&#x4E0B;&#x662F;&#x6211;&#x8A8D;&#x70BA;&#x5FC5;&#x5099;&#x7684;&#x63D2;&#x4EF6;&#xFF0C;&#x5B83;&#x5011;&#x5927;&#x5927;&#x63D0;&#x5347;&#x4E86;&#x7CFB;&#x7D71;&#x7684;&#x529F;&#x80FD;&#x548C;&#x4F7F;&#x7528;&#x9AD4;&#x9A57;&#x3002;</p>
<h2 id="community-applications">Community Applications</h2>
<p>&#x5728; 6.10.x &#x53CA;&#x4EE5;&#x4E0A;&#x7248;&#x672C;&#x4E2D;&#x8981;&#x5B89;&#x88DD; CA&#xFF0C;&#x53EF;&#x4EE5;&#x524D;&#x5F80; unRAID&#x4ECB;&#x9762;&#x4E2D;&#x5DF2;&#x5B58;&#x5728;&#x7684;&#x300C;APPS&#x300D;&#x6A19;&#x7C64;&#xFF0C;&#x7CFB;&#x7D71;&#x6703;&#x63D0;&#x793A;&#x60A8;&#x81EA;&#x52D5;&#x5B89;&#x88DD;&#x3002;</p>
<p>&#x5C0D;&#x65BC;&#x8F03;&#x820A;&#x7248;&#x672C;&#x7684; unRAID&#xFF0C;&#x8ACB;&#x5C07;&#x4EE5;&#x4E0B; URL &#x8CBC;&#x5165; &#x300C;PLUGINS&#x300D; &gt; &#x300C;Install Plugin&#x300D; &#x4E2D;:</p>
<pre><code class="language-bash">https://raw.githubusercontent.com/Squidly271/community.applications/master/plugins/community.applications.plg</code></pre>
<p>&#x95DC;&#x65BC;Community Applications&#x7684;&#x8AAA;&#x660E;&#x53EF;&#x4EE5;&#x5728;<a href="https://forums.unraid.net/topic/38582-plug-in-community-applications/?ref=ghost.augustushsu.com">&#x5B98;&#x65B9;&#x7684;&#x8AD6;&#x58C7;&#x4E2D;</a>&#x770B;&#x5230;&#x3002;</p>
<h2 id="language">Language</h2>
<p>&#x8A9E;&#x8A00;&#x7684;&#x90E8;&#x5206;&#x9700;&#x8981;&#x5728;&#x300C;APPS&#x300D;&#x4E2D;&#x5B89;&#x88DD;&#x76F8;&#x95DC;&#x7684;&#x8A9E;&#x8A00;&#x5305; (APP&#x529F;&#x80FD;&#x7684;&#x555F;&#x7528;&#x5728;&#x4E0B;&#x65B9;&#x6709;&#x4ECB;&#x7D39;)&#xFF0C;&#x5B89;&#x88DD;&#x5F8C;&#x53EF;&#x4EE5;&#x5728;&#x4E0A;&#x65B9;&#x7684;&#x300C;Actions&#x300D;&#x4E2D;&#x9078;&#x64C7;&#x5207;&#x63DB;&#x8A72;&#x8A9E;&#x8A00;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-11.png" class="kg-image" alt="unRAID Server Note 02" loading="lazy" width="851" height="788" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-11.png 600w, https://ghost.augustushsu.com/content/images/2024/09/image-11.png 851w" sizes="(min-width: 720px) 720px"></figure>
<p>&#x4E5F;&#x53EF;&#x4EE5;&#x5728;&#x53F3;&#x4E0A;&#x65B9;&#x7684;&#x9019;&#x500B;&#x5716;&#x793A;&#x4E2D;&#x9078;&#x64C7;&#x5207;&#x63DB; (&#x76EE;&#x524D;&#x6E2C;&#x8A66;&#x6642;&#x767C;&#x73FE;&#x9700;&#x8981;&#x5148;&#x900F;&#x904E;&#x4E0A;&#x65B9;&#x7684;&#x65B9;&#x5F0F;&#x5207;&#x63DB;&#x4E00;&#x6B21;&#x8A9E;&#x8A00;&#x5F8C;&#x624D;&#x80FD;&#x900F;&#x904E;&#x9019;&#x500B;&#x5716;&#x793A;&#x5207;&#x63DB;) :</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-12.png" class="kg-image" alt="unRAID Server Note 02" loading="lazy" width="408" height="181"></figure>
<h2 id="nerd-tools">Nerd Tools</h2>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-16.png" class="kg-image" alt="unRAID Server Note 02" loading="lazy" width="501" height="349"></figure>
<p>&#x5728;&#x65E5;&#x5E38;&#x4F7F;&#x7528;unRAID&#x7684;&#x904E;&#x7A0B;&#x4E2D;&#xFF0C;&#x60A8;&#x53EF;&#x80FD;&#x6703;&#x9700;&#x8981;&#x4E00;&#x4E9B;&#x547D;&#x4EE4;&#x5217;&#x5DE5;&#x5177;&#x4F86;&#x5B8C;&#x6210;&#x7279;&#x5B9A;&#x7684;&#x4EFB;&#x52D9;&#x3002;&#x7136;&#x800C;&#xFF0C;unRAID&#x7CFB;&#x7D71;&#x672C;&#x8EAB;&#x4E26;&#x4E0D;&#x9810;&#x88DD;&#x9019;&#x4E9B;&#x5DE5;&#x5177;&#xFF0C;&#x9019;&#x7D66;&#x7528;&#x6236;&#x5E36;&#x4F86;&#x4E86;&#x4E00;&#x5B9A;&#x7684;&#x4E0D;&#x4FBF;&#x3002;</p>
<ul><li><strong>&#x7F3A;&#x4E4F;&#x5957;&#x4EF6;&#x7BA1;&#x7406;&#x5668;: </strong>unRAID&#x57FA;&#x65BC; Slackware Linux&#xFF0C;&#x4F46;&#x5B83;&#x4E0D;&#x63D0;&#x4F9B;&#x50CF; <code>apt</code>&#xFF08;Debian/Ubuntu&#xFF09;&#x6216; <code>yum</code>&#xFF08;CentOS/Fedora&#xFF09;&#x9019;&#x6A23;&#x7684;&#x5957;&#x4EF6;&#x7BA1;&#x7406;&#x5DE5;&#x5177;&#x3002;&#x9019;&#x4F7F;&#x5F97;&#x5B89;&#x88DD;&#x8EDF;&#x9AD4;&#x8B8A;&#x5F97;&#x76F8;&#x5C0D;&#x9EBB;&#x7169;&#x3002;</li><li><strong>&#x8EDF;&#x9AD4;&#x517C;&#x5BB9;&#x6027;&#x554F;&#x984C;: </strong>&#x5927;&#x591A;&#x6578;&#x8EDF;&#x9AD4;&#x4E0D;&#x6703;&#x63D0;&#x4F9B;&#x91DD;&#x5C0D; Slackware &#x7684;&#x7DE8;&#x8B6F;&#x7248;&#x672C;&#xFF0C;&#x5C0E;&#x81F4;&#x76F4;&#x63A5;&#x5B89;&#x88DD;&#x9810;&#x7DE8;&#x8B6F;&#x5957;&#x4EF6;&#x8B8A;&#x5F97;&#x56F0;&#x96E3;&#x3002;</li><li><strong>&#x81EA;&#x884C;&#x7DE8;&#x8B6F;&#x7684;&#x8907;&#x96DC;&#x6027;: </strong>&#x5982;&#x679C;&#x9078;&#x64C7;&#x81EA;&#x884C;&#x7DE8;&#x8B6F;&#x8EDF;&#x9AD4;&#xFF0C;&#x60A8;&#x9700;&#x8981;&#x5EFA;&#x7ACB;&#x5B8C;&#x6574;&#x7684;&#x7DE8;&#x8B6F;&#x74B0;&#x5883;&#xFF0C;&#x9019;&#x4E0D;&#x50C5;&#x8907;&#x96DC;&#xFF0C;&#x800C;&#x4E14;&#x5BB9;&#x6613;&#x51FA;&#x73FE;&#x932F;&#x8AA4;&#x3002;</li><li><strong>&#x8017;&#x6642;&#x8CBB;&#x529B;: </strong>&#x6BCF;&#x6B21;&#x9700;&#x8981;&#x5B89;&#x88DD;&#x65B0;&#x7684;&#x8EDF;&#x9AD4;&#xFF0C;&#x90FD;&#x9700;&#x8981;&#x624B;&#x52D5;&#x7DE8;&#x8B6F;&#xFF0C;&#x9019;&#x975E;&#x5E38;&#x8017;&#x6642;&#x4E14;&#x6548;&#x7387;&#x4F4E;&#x4E0B;&#x3002;</li></ul>
<p>&#x70BA;&#x4E86;&#x89E3;&#x6C7A;&#x9019;&#x4E9B;&#x554F;&#x984C;&#xFF0C;Nerd Tools Plugin&#x70BA; unRAID&#x7528;&#x6236;&#x63D0;&#x4F9B;&#x4E86;&#x4E00;&#x500B;&#x4FBF;&#x5229;&#x7684;&#x89E3;&#x6C7A;&#x65B9;&#x6848;: </p>
<ul><li><strong>&#x96C6;&#x5408;&#x5E38;&#x7528;&#x5DE5;&#x5177;: </strong>Nerd Tools &#x5305;&#x542B;&#x4E86;&#x8A31;&#x591A;&#x5E38;&#x7528;&#x7684;&#x547D;&#x4EE4;&#x5217;&#x5DE5;&#x5177;&#xFF0C;&#x60A8;&#x53EF;&#x4EE5;&#x6839;&#x64DA;&#x9700;&#x8981;&#x9078;&#x64C7;&#x6027;&#x5730;&#x5B89;&#x88DD;&#x3002;</li><li><strong>&#x7C21;&#x5316;&#x5B89;&#x88DD;&#x6D41;&#x7A0B;: </strong>&#x901A;&#x904E;&#x5716;&#x5F62;&#x5316;&#x4ECB;&#x9762;&#xFF0C;&#x60A8;&#x53EF;&#x4EE5;&#x8F15;&#x9B06;&#x5730;&#x5728; unRAID&#x4E0A;&#x5B89;&#x88DD;&#x6240;&#x9700;&#x7684;&#x5DE5;&#x5177;&#xFF0C;&#x800C;&#x7121;&#x9700;&#x624B;&#x52D5;&#x7DE8;&#x8B6F;&#x3002;</li><li><strong>&#x63D0;&#x9AD8;&#x6548;&#x7387;: </strong>&#x6E1B;&#x5C11;&#x4E86;&#x5EFA;&#x7ACB;&#x7DE8;&#x8B6F;&#x74B0;&#x5883;&#x548C;&#x624B;&#x52D5;&#x7DE8;&#x8B6F;&#x7684;&#x6642;&#x9593;&#xFF0C;&#x4F7F;&#x60A8;&#x80FD;&#x66F4;&#x5C08;&#x6CE8;&#x65BC;&#x5BE6;&#x969B;&#x4EFB;&#x52D9;&#x3002;</li></ul>
<p>&#x5F9E;&#x300C;SETTINGS&#x300D;&gt;&#x300C;NerdTools&#x300D;&#x53EF;&#x4EE5;&#x9032;&#x5230;&#x7BA1;&#x7406;&#x5957;&#x4EF6;&#x7684;&#x4ECB;&#x9762;&#xFF0C;&#x641C;&#x5C0B;&#x8981;&#x5B89;&#x88DD;&#x7684;&#x5957;&#x4EF6;&#x9EDE;&#x9078;&#x5DE6;&#x908A;&#x7684;&#x6309;&#x9215;&#x518D;&#x9EDE;&#x4E0B;APPLY&#x5C31;&#x53EF;&#x4EE5;&#x5B89;&#x88DD;&#x4E86;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-15.png" class="kg-image" alt="unRAID Server Note 02" loading="lazy" width="1859" height="260" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-15.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2024/09/image-15.png 1000w, https://ghost.augustushsu.com/content/images/size/w1600/2024/09/image-15.png 1600w, https://ghost.augustushsu.com/content/images/2024/09/image-15.png 1859w" sizes="(min-width: 720px) 720px"></figure>
<p>&#x9019;&#x908A;&#x63A8;&#x85A6;&#x5E7E;&#x500B;&#x53EF;&#x4EE5;&#x5B89;&#x88DD;&#x7684;&#x5957;&#x4EF6;:</p>
<ol><li><strong>vim</strong>: &#x529F;&#x80FD;&#x5F37;&#x5927;&#x7684;&#x6587;&#x5B57;&#x7DE8;&#x8F2F;&#x5668;&#xFF0C;&#x9069;&#x5408;&#x7DE8;&#x8F2F;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x548C;&#x7DE8;&#x5BEB;&#x8173;&#x672C;&#x3002;</li><li><strong>iotop</strong>: &#x5BE6;&#x6642;&#x986F;&#x793A;&#x78C1;&#x76E4; I/O &#x4F7F;&#x7528;&#x60C5;&#x6CC1;&#xFF0C;&#x53EF;&#x4EE5;&#x627E;&#x51FA;&#x4F54;&#x7528;&#x5927;&#x91CF;&#x78C1;&#x76E4;&#x8B80;&#x5BEB;&#x7684;&#x9032;&#x7A0B;&#x3002;</li><li><strong>ncdu</strong>: &#x78C1;&#x76E4;&#x4F7F;&#x7528;&#x5206;&#x6790;&#x5DE5;&#x5177;&#xFF0C;&#x5E6B;&#x52A9;&#x60A8;&#x67E5;&#x770B;&#x54EA;&#x4E9B;&#x6587;&#x4EF6;&#x6216;&#x76EE;&#x9304;&#x4F54;&#x7528;&#x4E86;&#x6700;&#x591A;&#x7A7A;&#x9593;&#x3002;</li><li><strong>iftop</strong>: &#x7DB2;&#x7D61;&#x6D41;&#x91CF;&#x76E3;&#x63A7;&#x5DE5;&#x5177;&#xFF0C;&#x5BE6;&#x6642;&#x986F;&#x793A;&#x7576;&#x524D;&#x7DB2;&#x7D61;&#x9023;&#x63A5;&#x548C;&#x6D41;&#x91CF;&#x4F7F;&#x7528;&#x60C5;&#x6CC1;&#x3002;</li></ol>
<p>&#x89E3;&#x9664;&#x5B89;&#x88DD;&#x4E5F;&#x5F88;&#x7C21;&#x55AE;&#xFF0C;&#x9EDE;&#x9078;&#x8981;&#x89E3;&#x9664;&#x5B89;&#x88DD;&#x7684;&#x5DE5;&#x5177;&#x5C07;&#x5176;&#x8B8A;&#x6210;OFF&#x518D;&#x9EDE;&#x9078;APPLY&#x5C31;&#x53EF;&#x4EE5;&#x4E86;&#xFF0C;&#x6709;&#x770B;&#x5230;&#x5176;&#x4ED6;&#x7FD2;&#x6163;&#x6216;&#x5E38;&#x7528;&#x7684;&#x5DE5;&#x5177;&#x53EF;&#x4EE5;&#x81EA;&#x884C;&#x4E0B;&#x8F09;&#x3002;</p>
<h2 id="appdata-backup"><strong>Appdata Backup</strong></h2>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-17.png" class="kg-image" alt="unRAID Server Note 02" loading="lazy" width="498" height="340"></figure>
<div class="kg-card kg-callout-card kg-callout-card-blue"><div class="kg-callout-emoji">&#x1F4A1;</div><div class="kg-callout-text"><a href="https://forums.unraid.net/topic/137710-plugin-appdatabackup/?ref=ghost.augustushsu.com">Appdata Backup</a> &#x53EA;&#x652F;&#x63F4;&#x2265;6.12&#x7684;&#x7CFB;&#x7D71;&#x7248;&#x672C;&#xFF0C;&#x5982;&#x679C;&#x4F60;&#x7684;&#x7CFB;&#x7D71;&#x7248;&#x672C;&lt;6.12&#xFF0C;&#x90A3;&#x9EBC;&#x63D2;&#x4EF6;&#x5C07;&#x6703;&#x662F;&#x53E6;&#x4E00;&#x500B;&#x7248;&#x672C;&#xFF0C;&#x540D;&#x7A31;&#x53EB;&#x505A;Appdata Backup v2.5&#x3002;</div></div>
<h3 id="%E5%82%99%E4%BB%BD">&#x5099;&#x4EFD;</h3>
<p>&#x9019;&#x500B;<a href="https://www.jackiewu.top/article/appdata-backup?ref=ghost.augustushsu.com"><strong>&#x7DB2;&#x7AD9;</strong></a>&#x4E0A;&#x6709;&#x8A73;&#x7D30;&#x7684;&#x4ECB;&#x7D39;&#xFF0C;&#x4EE5;&#x4E0B;&#x662F;&#x6211;&#x7684;&#x8A2D;&#x5B9A;&#xFF0C;&#x8A2D;&#x5B9A;&#x522A;&#x9664;&#x8D85;&#x904E;120&#x5929;&#x7684;&#x8F29;&#x5206;&#xFF0C;&#x81F3;&#x5C11;&#x5B58;3&#x4EFD;&#x8A2D;&#x5B9A;&#x6A94;&#x3001;&#x8D85;&#x904E;&#x5C31;&#x522A;&#x9664;&#x6700;&#x65E9;&#x7684;&#x90A3;&#x4EFD;&#xFF0C;&#x8A2D;&#x5B9A;&#x8981;&#x5099;&#x4EFD;&#x7684;&#x4F4D;&#x7F6E; (appdata&#x7684;&#x4F4D;&#x7F6E;)&#x3001;&#x5099;&#x4EFD;&#x5230;&#x54EA;&#x500B;&#x8CC7;&#x6599;&#x593E;&#x3001;&#x662F;&#x5426;&#x58D3;&#x7E2E; (&#x4F7F;&#x7528;<a href="https://facebook.github.io/zstd/?ref=ghost.augustushsu.com">zstdmt</a>&#x58D3;&#x7E2E;&#x65B9;&#x6CD5;)&#xFF0C;&#x540C;&#x6642;&#x5099;&#x4EFD;flash&#x8DDF;VM&#x7684;&#x8CC7;&#x6599;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-24.png" class="kg-image" alt="unRAID Server Note 02" loading="lazy" width="1296" height="630" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-24.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2024/09/image-24.png 1000w, https://ghost.augustushsu.com/content/images/2024/09/image-24.png 1296w" sizes="(min-width: 720px) 720px"></figure>
<p>&#x9019;&#x88E1;&#x7684;&#x8A2D;&#x5B9A;&#x70BA;&#x662F;&#x5426;&#x8DF3;&#x904E;&#x95DC;&#x9589;&#x7684;containers&#x3001;&#x662F;&#x5426;&#x9A57;&#x8B49;&#x5099;&#x4EFD;&#x3001;&#x5FFD;&#x7565;&#x5099;&#x4EFD;&#x6642;&#x767C;&#x751F;&#x7684;&#x932F;&#x8AA4;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-19.png" class="kg-image" alt="unRAID Server Note 02" loading="lazy" width="905" height="285" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-19.png 600w, https://ghost.augustushsu.com/content/images/2024/09/image-19.png 905w" sizes="(min-width: 720px) 720px"></figure>
<p>&#x9019;&#x908A;&#x8A2D;&#x5B9A;&#x7684;&#x662F;&#x901A;&#x77E5;&#x548C;&#x5099;&#x4EFD;&#x7684;&#x6642;&#x6A5F;&#x9EDE;&#xFF0C;&#x8A2D;&#x5B9A;&#x70BA;&#x53EA;&#x901A;&#x77E5;&#x932F;&#x8AA4;&#x8A0A;&#x606F;&#x3001;&#x6BCF;&#x500B;&#x6708;&#x7B2C;&#x4E8C;&#x5929;&#x534A;&#x591C;3&#x9EDE;30&#x5206;&#x958B;&#x59CB;&#x5099;&#x4EFD;&#xFF0C;&#x4E3B;&#x8981;&#x662F;&#x70BA;&#x4E86;&#x932F;&#x958B;&#x6AA2;&#x67E5;&#x5947;&#x5076;&#x6821;&#x9A57;&#x7684;&#x6642;&#x9593;&#x9EDE;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-20.png" class="kg-image" alt="unRAID Server Note 02" loading="lazy" width="1055" height="532" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-20.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2024/09/image-20.png 1000w, https://ghost.augustushsu.com/content/images/2024/09/image-20.png 1055w" sizes="(min-width: 720px) 720px"></figure>
<p>&#x662F;&#x5426;&#x5728;&#x5099;&#x4EFD;&#x5B8C;&#x5F8C;&#x66F4;&#x65B0;container:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-21.png" class="kg-image" alt="unRAID Server Note 02" loading="lazy" width="1208" height="171" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-21.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2024/09/image-21.png 1000w, https://ghost.augustushsu.com/content/images/2024/09/image-21.png 1208w" sizes="(min-width: 720px) 720px"></figure>
<p>&#x63A5;&#x4E0B;&#x4F86;&#x7684;&#x8A2D;&#x5B9A;&#x70BA;&#x662F;&#x5426;&#x9700;&#x8981;&#x8DF3;&#x904E;&#x500B;&#x5225;&#x7684;container&#x3001;&#x662F;&#x5426;&#x9700;&#x8981;&#x5132;&#x5B58;appdata&#x8CC7;&#x6599;&#x593E;&#x4EE5;&#x5916;&#x7684;&#x8CC7;&#x6599;&#x593E;&#x3001;&#x662F;&#x5426;&#x5728;&#x4E0D;&#x505C;&#x6B62;Docker &#x7684;&#x60C5;&#x6CC1;&#x4E0B;&#x9032;&#x884C;&#x5099;&#x4EFD;&#xFF0C;&#x4E00;&#x822C;&#x4FDD;&#x6301;&#x9810;&#x8A2D;&#x503C;&#x5373;&#x53EF;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-25.png" class="kg-image" alt="unRAID Server Note 02" loading="lazy" width="1153" height="513" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-25.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2024/09/image-25.png 1000w, https://ghost.augustushsu.com/content/images/2024/09/image-25.png 1153w" sizes="(min-width: 720px) 720px"></figure>
<p>&#x5269;&#x9918;&#x7684;&#x8A2D;&#x5B9A;&#x6211;&#x9019;&#x908A;&#x70BA;&#x7A7A;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-26.png" class="kg-image" alt="unRAID Server Note 02" loading="lazy" width="1307" height="712" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-26.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2024/09/image-26.png 1000w, https://ghost.augustushsu.com/content/images/2024/09/image-26.png 1307w" sizes="(min-width: 720px) 720px"></figure>
<h3 id="%E9%82%84%E5%8E%9F">&#x9084;&#x539F;</h3>
<p>&#x9084;&#x539F;&#x65B9;&#x5F0F;&#x5F88;&#x7C21;&#x55AE;&#xFF0C;&#x9078;&#x64C7;Restore&#x6A19;&#x7C64;&#x9801;&#x3001;&#x518D;&#x9078;&#x64C7;&#x5099;&#x4EFD;&#x7684;&#x4F86;&#x6E90;&#xFF0C;&#x9EDE;&#x9078;NEXT&#xFF0C;&#x5C31;&#x53EF;&#x4EE5;&#x9078;&#x64C7;&#x5099;&#x4EFD;&#x7684;&#x7248;&#x672C;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-27.png" class="kg-image" alt="unRAID Server Note 02" loading="lazy" width="1801" height="895" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-27.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2024/09/image-27.png 1000w, https://ghost.augustushsu.com/content/images/size/w1600/2024/09/image-27.png 1600w, https://ghost.augustushsu.com/content/images/2024/09/image-27.png 1801w" sizes="(min-width: 720px) 720px"></figure>
<p>&#x5F8C;&#x7E8C;&#x5148;&#x9019;&#x908A;&#x53C3;&#x8003;<a href="https://www.jackiewu.top/article/appdata-backup?ref=ghost.augustushsu.com">&#x9019;&#x908A;</a>&#x7684;&#x8655;&#x7406;&#xFF0C;&#x6709;&#x6A5F;&#x6703;&#x518D;&#x88DC;&#x4E0A;&#x3002;</p>
<h2 id="fix-common-problems">Fix Common Problems</h2>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-32.png" class="kg-image" alt="unRAID Server Note 02" loading="lazy" width="437" height="300"></figure>
<p>Fix Common Problems&#x662F;unRAID&#x7CFB;&#x7D71;&#x4E0A;&#x4E00;&#x6B3E;&#x5FC5;&#x5099;&#x7684;&#x8A3A;&#x65B7;&#x548C;&#x6545;&#x969C;&#x6392;&#x9664;&#x63D2;&#x4EF6;&#xFF0C;&#x4E3B;&#x8981;&#x529F;&#x80FD;&#x662F;&#x5E6B;&#x52A9;&#x7528;&#x6236;&#x81EA;&#x52D5;&#x6AA2;&#x6E2C;&#x548C;&#x89E3;&#x6C7A;&#x7CFB;&#x7D71;&#x4E2D;&#x53EF;&#x80FD;&#x5B58;&#x5728;&#x7684;&#x5404;&#x7A2E;&#x5E38;&#x898B;&#x554F;&#x984C;&#xFF0C;&#x5305;&#x62EC;&#x914D;&#x7F6E;&#x932F;&#x8AA4;&#x3001;&#x63D2;&#x4EF6;&#x885D;&#x7A81;&#x3001;&#x786C;&#x9AD4;&#x6545;&#x969C;&#x7B49;&#x3002;&#x901A;&#x904E;&#x5B9A;&#x671F;&#x904B;&#x884C;&#xFF0C;&#x53EF;&#x4EE5;&#x78BA;&#x4FDD;unRAID&#x7CFB;&#x7D71;&#x59CB;&#x7D42;&#x8655;&#x65BC;&#x6700;&#x4F73;&#x72C0;&#x614B;&#xFF0C;&#x907F;&#x514D;&#x6F5B;&#x5728;&#x7684;&#x6545;&#x969C;&#x548C;&#x6578;&#x64DA;&#x640D;&#x5931;&#x3002;</p>
<p>&#x4ED6;&#x53EF;&#x4EE5;&#x5B9A;&#x671F;&#x6216;&#x6309;&#x9700;&#x6383;&#x63CF;&#x7CFB;&#x7D71;&#xFF0C;&#x6AA2;&#x67E5;&#x7CFB;&#x7D71;&#x8A2D;&#x7F6E;&#x3001;&#x63D2;&#x4EF6;&#x3001;Docker &#x5BB9;&#x5668;&#x548C; VM &#x7684;&#x6F5B;&#x5728;&#x554F;&#x984C;&#xFF0C;&#x540C;&#x6642;&#x63D0;&#x4F9B;&#x554F;&#x984C;&#x7684;&#x8A73;&#x7D30;&#x63CF;&#x8FF0;&#x548C;&#x53EF;&#x80FD;&#x7684;&#x5F71;&#x97FF;&#xFF0C;&#x70BA;&#x6BCF;&#x500B;&#x554F;&#x984C;&#x63D0;&#x4F9B;&#x5177;&#x9AD4;&#x7684;&#x89E3;&#x6C7A;&#x5EFA;&#x8B70;&#x548C;&#x6307;&#x5C0E;&#x3002;&#x5B83;&#x64C1;&#x6709;&#x76F4;&#x89C0;&#x7684;&#x7528;&#x6236;&#x754C;&#x9762;&#xFF0C;&#x65B9;&#x4FBF;&#x65B0;&#x624B;&#x548C;&#x9AD8;&#x7D1A;&#x7528;&#x6236;&#x4F7F;&#x7528;&#xFF0C;&#x4E00;&#x9375;&#x5C31;&#x53EF;&#x4EE5;&#x904B;&#x884C;&#x6383;&#x63CF;&#xFF0C;&#x5FEB;&#x901F;&#x7372;&#x53D6;&#x7D50;&#x679C;&#x3002;&#x4E00;&#x65E6;&#x767C;&#x73FE;&#x554F;&#x984C;&#x53EF;&#x4EE5;&#x901A;&#x904E;unRAID&#x7684;&#x901A;&#x77E5;&#x7CFB;&#x7D71;&#x63D0;&#x9192;&#x7528;&#x6236;&#x9700;&#x8981;&#x95DC;&#x6CE8;&#x7684;&#x554F;&#x984C;</p>
<p>&#x5B89;&#x88DD;&#x5B8C;&#x6210;&#x5F8C;&#x53EF;&#x4EE5;&#x5728;<strong>&#x300C;</strong>Plugins<strong>&#x300D;</strong>&#x627E;&#x5230;&quot;Fix Common Problems&quot;&#xFF0C;&#x9EDE;&#x64CA;&#x300C;Run Scan&#x300D;&#x6309;&#x9215;&#xFF0C;&#x5C31;&#x53EF;&#x4EE5;&#x958B;&#x59CB;&#x7CFB;&#x7D71;&#x6383;&#x63CF;&#x3002;&#x6383;&#x63CF;&#x5B8C;&#x6210;&#x5F8C;&#xFF0C;&#x63D2;&#x4EF6;&#x6703;&#x5217;&#x51FA;&#x6240;&#x6709;&#x767C;&#x73FE;&#x7684;&#x554F;&#x984C;&#xFF0C;&#x6BCF;&#x500B;&#x554F;&#x984C;&#x90FD;&#x5305;&#x542B;&#x8A73;&#x7D30;&#x7684;&#x63CF;&#x8FF0;&#x548C;&#x5EFA;&#x8B70;&#x7684;&#x89E3;&#x6C7A;&#x65B9;&#x6848;&#xFF0C;&#x6839;&#x64DA;&#x63D2;&#x4EF6;&#x7684;&#x5EFA;&#x8B70;&#xFF0C;&#x63A1;&#x53D6;&#x76F8;&#x61C9;&#x7684;&#x63AA;&#x65BD;&#x4F86;&#x4FEE;&#x5FA9;&#x554F;&#x984C;&#x3002;</p>
<p>&#x5E38;&#x898B;&#x6AA2;&#x6E2C;&#x9805;&#x76EE;&#x6709;&#x4EE5;&#x4E0B;&#x5E7E;&#x7A2E;&#xFF1A;</p>
<ul><li>&#x914D;&#x7F6E;&#x932F;&#x8AA4;&#xFF1A; &#x6AA2;&#x67E5;&#x4E0D;&#x5408;&#x7406;&#x7684;&#x7CFB;&#x7D71;&#x8A2D;&#x7F6E;&#xFF0C;&#x5982;&#x4E0D;&#x6B63;&#x78BA;&#x7684;&#x7DB2;&#x7D61;&#x914D;&#x7F6E;&#x3001;&#x5171;&#x4EAB;&#x8A2D;&#x7F6E;&#x7B49;&#x3002;</li><li>&#x63D2;&#x4EF6;&#x554F;&#x984C;&#xFF1A; &#x6AA2;&#x6E2C;&#x904E;&#x6642;&#x3001;&#x885D;&#x7A81;&#x6216;&#x5DF2;&#x77E5;&#x6709;&#x554F;&#x984C;&#x7684;&#x63D2;&#x4EF6;&#x3002;</li><li>Docker &#x5BB9;&#x5668;&#xFF1A; &#x8B58;&#x5225;&#x6709;&#x6F5B;&#x5728;&#x554F;&#x984C;&#x7684; Docker &#x6620;&#x50CF;&#x6216;&#x914D;&#x7F6E;&#x932F;&#x8AA4;&#x3002;</li><li>&#x786C;&#x9AD4;&#x6545;&#x969C;&#xFF1A; &#x6AA2;&#x67E5;&#x78C1;&#x76E4;&#x932F;&#x8AA4;&#x3001;&#x6EAB;&#x5EA6;&#x904E;&#x9AD8;&#x7B49;&#x786C;&#x9AD4;&#x76F8;&#x95DC;&#x554F;&#x984C;&#x3002;</li><li>&#x5B89;&#x5168;&#x98A8;&#x96AA;&#xFF1A; &#x63D0;&#x793A;&#x6F5B;&#x5728;&#x7684;&#x5B89;&#x5168;&#x6F0F;&#x6D1E;&#xFF0C;&#x5982;&#x5F31;&#x5BC6;&#x78BC;&#x3001;&#x672A;&#x53D7;&#x4FDD;&#x8B77;&#x7684;&#x5171;&#x4EAB;&#x7B49;</li></ul>
<p>Fix Common Problems &#x63D2;&#x4EF6;&#x662F;&#x7DAD;&#x8B77;unRAID&#x7CFB;&#x7D71;&#x7A69;&#x5B9A;&#x6027;&#x548C;&#x53EF;&#x9760;&#x6027;&#x7684;&#x5F37;&#x5927;&#x5DE5;&#x5177;&#x3002;&#x901A;&#x904E;&#x81EA;&#x52D5;&#x6AA2;&#x6E2C;&#x548C;&#x63D0;&#x793A;&#x6F5B;&#x5728;&#x554F;&#x984C;&#xFF0C;&#x60A8;&#x53EF;&#x4EE5;&#x4E3B;&#x52D5;&#x89E3;&#x6C7A;&#x53EF;&#x80FD;&#x5F71;&#x97FF;&#x7CFB;&#x7D71;&#x6027;&#x80FD;&#x548C;&#x5B89;&#x5168;&#x6027;&#x7684;&#x96B1;&#x60A3;&#x3002;&#x7121;&#x8AD6;&#x60A8;&#x662F;&#x65B0;&#x624B;&#x9084;&#x662F;&#x6709;&#x7D93;&#x9A57;&#x7684;&#x7528;&#x6236;&#xFF0C;&#x5B89;&#x88DD;&#x548C;&#x4F7F;&#x7528; FCP &#x90FD;&#x80FD;&#x8B93;&#x60A8;&#x7684;unRAID&#x7CFB;&#x7D71;&#x904B;&#x884C;&#x5F97;&#x66F4;&#x52A0;&#x9806;&#x66A2;&#x548C;&#x5B89;&#x5168;&#x3002;</p>
<h2 id="ca-auto-turbo-write-mode">CA Auto Turbo Write Mode</h2>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-33.png" class="kg-image" alt="unRAID Server Note 02" loading="lazy" width="438" height="296"></figure>
<p>CA Auto Turbo Write Mode &#x662F;unRAID&#x4E2D;&#x4E00;&#x6B3E;&#x80FD;&#x5920;&#x81EA;&#x52D5;&#x7BA1;&#x7406;&#x5BEB;&#x5165;&#x6A21;&#x5F0F;&#x7684;&#x63D2;&#x4EF6;&#xFF0C;&#x65E8;&#x5728;&#x6839;&#x64DA;&#x7CFB;&#x7D71;&#x8CA0;&#x8F09;&#x81EA;&#x52D5;&#x5207;&#x63DB;unRAID&#x7684;&#x5BEB;&#x5165;&#x6A21;&#x5F0F;&#xFF0C;&#x5BE6;&#x73FE;&#x6027;&#x80FD;&#x8207;&#x80FD;&#x6E90;&#x6548;&#x7387;&#x4E4B;&#x9593;&#x7684;&#x5E73;&#x8861;&#x3002;</p>
<p>&#x5728;unRAID&#x4E2D;&#xFF0C;&#x6709;&#x5169;&#x7A2E;&#x4E3B;&#x8981;&#x7684;&#x5BEB;&#x5165;&#x6A21;&#x5F0F;&#xFF1A;</p>
<ol><li><strong>&#x9ED8;&#x8A8D;&#x6A21;&#x5F0F;&#xFF08;Read/Modify/Write&#xFF09;&#xFF1A;</strong> &#x5BEB;&#x5165;&#x6578;&#x64DA;&#x6642;&#x50C5;&#x9700;&#x8981;&#x555F;&#x52D5;&#x76F8;&#x95DC;&#x7684;&#x6578;&#x64DA;&#x76E4;&#x548C;&#x6821;&#x9A57;&#x76E4;&#xFF0C;&#x9019;&#x7A2E;&#x6A21;&#x5F0F;&#x529F;&#x8017;&#x8F03;&#x4F4E;&#xFF0C;&#x4F46;&#x5BEB;&#x5165;&#x901F;&#x5EA6;&#x76F8;&#x5C0D;&#x8F03;&#x6162;&#x3002;</li><li><strong>Turbo Write &#x6A21;&#x5F0F;&#xFF08;Reconstruct Write&#xFF09;&#xFF1A;</strong> &#x5BEB;&#x5165;&#x6578;&#x64DA;&#x6642;&#x6703;&#x555F;&#x52D5;&#x6240;&#x6709;&#x6578;&#x64DA;&#x76E4;&#x548C;&#x6821;&#x9A57;&#x76E4;&#xFF0C;&#x901A;&#x904E;&#x91CD;&#x5EFA;&#x6578;&#x64DA;&#x4F86;&#x63D0;&#x9AD8;&#x5BEB;&#x5165;&#x901F;&#x5EA6;&#xFF0C;&#x4F46;&#x529F;&#x8017;&#x548C;&#x786C;&#x76E4;&#x78E8;&#x640D;&#x8F03;&#x5927;&#x3002;</li></ol>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-35.png" class="kg-image" alt="unRAID Server Note 02" loading="lazy" width="1362" height="794" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-35.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2024/09/image-35.png 1000w, https://ghost.augustushsu.com/content/images/2024/09/image-35.png 1362w" sizes="(min-width: 720px) 720px"></figure>
<p><strong>CA Auto Turbo Write Mode &#x7684;&#x4E3B;&#x8981;&#x529F;&#x80FD;</strong>&#xFF1A;</p>
<ul><li><strong>&#x81EA;&#x52D5;&#x5207;&#x63DB;&#x5BEB;&#x5165;&#x6A21;&#x5F0F;</strong>&#xFF1A;&#x6839;&#x64DA;&#x78C1;&#x76E4;&#x6D3B;&#x52D5;&#x91CF;&#xFF0C;&#x52D5;&#x614B;&#x5728;&#x9ED8;&#x8A8D;&#x6A21;&#x5F0F;&#x548C; Turbo Write &#x6A21;&#x5F0F;&#x9593;&#x5207;&#x63DB;&#xFF0C;&#x7576;&#x7CFB;&#x7D71;&#x6709;&#x5927;&#x91CF;&#x5BEB;&#x5165;&#x64CD;&#x4F5C;&#x6642;&#x81EA;&#x52D5;&#x555F;&#x7528; Turbo Write&#xFF0C;&#x4EE5;&#x63D0;&#x5347;&#x6027;&#x80FD;&#xFF0C;&#x7576;&#x5BEB;&#x5165;&#x64CD;&#x4F5C;&#x8F03;&#x5C11;&#x6642;&#x56DE;&#x5230;&#x9ED8;&#x8A8D;&#x6A21;&#x5F0F;&#x4EE5;&#x7BC0;&#x7701;&#x80FD;&#x6E90;&#x3002;</li><li><strong>&#x63D0;&#x5347;&#x5BEB;&#x5165;&#x901F;&#x5EA6;</strong>&#xFF1A;&#x9069;&#x5408;&#x5927;&#x6578;&#x64DA;&#x50B3;&#x8F38;&#x7684;&#x5834;&#x666F;&#xFF0C;&#x986F;&#x8457;&#x63D0;&#x5347;&#x5BEB;&#x5165;&#x6548;&#x7387;&#xFF0C;&#x4E26;&#x5728;&#x4E0D;&#x9700;&#x8981;&#x9AD8;&#x6548;&#x80FD;&#x6642;&#x81EA;&#x52D5;&#x964D;&#x4F4E;&#x8CC7;&#x6E90;&#x6D88;&#x8017;&#x3002;</li></ul>
<h2 id="ca-auto-update-applications">CA Auto Update Applications</h2>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-34.png" class="kg-image" alt="unRAID Server Note 02" loading="lazy" width="435" height="302"></figure>
<p>CA Auto Update Applications&#x662F;unRAID&#x7684;&#x4E00;&#x6B3E;&#x63D2;&#x4EF6;&#xFF0C;&#x7528;&#x65BC;&#x81EA;&#x52D5;&#x66F4;&#x65B0;&#x7CFB;&#x7D71;&#x4E2D;&#x7684; Docker &#x5BB9;&#x5668;&#x3001;&#x63D2;&#x4EF6;&#x548C;&#x61C9;&#x7528;&#x7A0B;&#x5F0F;&#x3002;&#x9019;&#x6B3E;&#x5DE5;&#x5177;&#x5927;&#x5927;&#x7C21;&#x5316;&#x4E86;unRAID&#x7CFB;&#x7D71;&#x7684;&#x7DAD;&#x8B77;&#x5DE5;&#x4F5C;&#xFF0C;&#x78BA;&#x4FDD;&#x60A8;&#x7684;&#x61C9;&#x7528;&#x59CB;&#x7D42;&#x8655;&#x65BC;&#x6700;&#x65B0;&#x72C0;&#x614B;&#xFF0C;&#x5F9E;&#x800C;&#x63D0;&#x9AD8;&#x7CFB;&#x7D71;&#x7684;&#x7A69;&#x5B9A;&#x6027;&#x548C;&#x5B89;&#x5168;&#x6027;&#x3002;</p>
<p><strong>CA Auto Update Applications &#x7684;&#x4E3B;&#x8981;&#x529F;&#x80FD;&#xFF1A;</strong></p>
<ol><li><strong>&#x81EA;&#x52D5;&#x66F4;&#x65B0;</strong>&#xFF1A;&#x81EA;&#x52D5;&#x6AA2;&#x67E5;&#x4E26;&#x66F4;&#x65B0;&#x7CFB;&#x7D71;&#x4E2D;&#x7684; Docker &#x5BB9;&#x5668;&#x3001;&#x63D2;&#x4EF6;&#x548C;&#x61C9;&#x7528;&#x7A0B;&#x5F0F;&#xFF0C;&#x7121;&#x9700;&#x624B;&#x52D5;&#x64CD;&#x4F5C;&#xFF0C;&#x7BC0;&#x7701;&#x6642;&#x9593;&#x548C;&#x7CBE;&#x529B;&#x3002;</li><li><strong>&#x81EA;&#x5B9A;&#x7FA9;&#x66F4;&#x65B0;&#x983B;&#x7387;</strong>&#xFF1A;&#x7528;&#x6236;&#x53EF;&#x4EE5;&#x8A2D;&#x7F6E;&#x66F4;&#x65B0;&#x6AA2;&#x67E5;&#x7684;&#x983B;&#x7387;&#xFF08;&#x5982;&#x6BCF;&#x5929;&#x3001;&#x6BCF;&#x9031;&#xFF09;&#xFF0C;&#x4E26;&#x6839;&#x64DA;&#x9700;&#x8981;&#x81EA;&#x52D5;&#x57F7;&#x884C;&#x66F4;&#x65B0;&#x904E;&#x7A0B;&#x3002;</li><li><strong>&#x9748;&#x6D3B;&#x7684;&#x61C9;&#x7528;&#x7BA1;&#x7406;</strong>&#xFF1A;&#x7528;&#x6236;&#x53EF;&#x4EE5;&#x9078;&#x64C7;&#x54EA;&#x4E9B;&#x61C9;&#x7528;&#x7A0B;&#x5F0F;&#x6216;&#x63D2;&#x4EF6;&#x9700;&#x8981;&#x81EA;&#x52D5;&#x66F4;&#x65B0;&#xFF0C;&#x54EA;&#x4E9B;&#x5247;&#x4E0D;&#x9700;&#x8981;&#xFF0C;&#x9019;&#x6A23;&#x53EF;&#x4EE5;&#x9748;&#x6D3B;&#x63A7;&#x5236;&#x7CFB;&#x7D71;&#x66F4;&#x65B0;&#x3002;</li><li><strong>&#x901A;&#x77E5;&#x529F;&#x80FD;</strong>&#xFF1A;&#x7576;&#x66F4;&#x65B0;&#x5B8C;&#x6210;&#x6642;&#xFF0C;&#x7CFB;&#x7D71;&#x6703;&#x901A;&#x904E;&#x901A;&#x77E5;&#xFF08;&#x96FB;&#x5B50;&#x90F5;&#x4EF6;&#x6216;&#x5176;&#x4ED6;&#x63A8;&#x9001;&#x65B9;&#x5F0F;&#xFF09;&#x544A;&#x77E5;&#x7528;&#x6236;&#xFF0C;&#x78BA;&#x4FDD;&#x5C0D;&#x7CFB;&#x7D71;&#x8B8A;&#x66F4;&#x4FDD;&#x6301;&#x8FFD;&#x8E64;&#x3002;</li><li><strong>&#x66F4;&#x65B0;&#x65E5;&#x8A8C;</strong>&#xFF1A;&#x8A72;&#x63D2;&#x4EF6;&#x9084;&#x6703;&#x8A18;&#x9304;&#x66F4;&#x65B0;&#x65E5;&#x8A8C;&#xFF0C;&#x65B9;&#x4FBF;&#x7528;&#x6236;&#x96A8;&#x6642;&#x67E5;&#x770B;&#x66F4;&#x65B0;&#x904E;&#x7A0B;&#x548C;&#x7D50;&#x679C;&#x3002;</li></ol>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-36.png" class="kg-image" alt="unRAID Server Note 02" loading="lazy" width="1877" height="715" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-36.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2024/09/image-36.png 1000w, https://ghost.augustushsu.com/content/images/size/w1600/2024/09/image-36.png 1600w, https://ghost.augustushsu.com/content/images/2024/09/image-36.png 1877w" sizes="(min-width: 720px) 720px"></figure>
<p>CA Auto Update Applications&#x662F;&#x4E00;&#x500B;&#x975E;&#x5E38;&#x65B9;&#x4FBF;&#x7684;&#x5DE5;&#x5177;&#xFF0C;&#x8B93;unRAID&#x4F7F;&#x7528;&#x8005;&#x8F15;&#x9B06;&#x7BA1;&#x7406;&#x548C;&#x66F4;&#x65B0;&#x7CFB;&#x7D71;&#x4E2D;&#x7684;Docker&#x5BB9;&#x5668;&#x548C;&#x63D2;&#x4EF6;&#xFF0C;&#x4FDD;&#x6301;&#x7CFB;&#x7D71;&#x59CB;&#x7D42;&#x8655;&#x65BC;&#x6700;&#x4F73;&#x72C0;&#x614B;&#x3002;&#x5C0D;&#x65BC;&#x5E0C;&#x671B;&#x7C21;&#x5316;&#x7DAD;&#x8B77;&#x6D41;&#x7A0B;&#x4E26;&#x78BA;&#x4FDD;&#x7CFB;&#x7D71;&#x5B89;&#x5168;&#x548C;&#x7A69;&#x5B9A;&#x7684;&#x7528;&#x6236;&#x4F86;&#x8AAA;&#xFF0C;&#x9019;&#x662F;&#x4E0D;&#x53EF;&#x6216;&#x7F3A;&#x7684;&#x63D2;&#x4EF6;&#x3002;</p>
<h2 id="%E7%B5%90%E8%AB%96">&#x7D50;&#x8AD6;</h2>
<p>&#x5728;&#x9019;&#x7BC7;&#x6587;&#x7AE0;&#x4E2D;&#xFF0C;&#x4ECB;&#x7D39;&#x4E86;&#x5E7E;&#x500B;&#x5FC5;&#x5099;&#x7684;unRAID&#x63D2;&#x4EF6;&#xFF0C;&#x9019;&#x4E9B;&#x5DE5;&#x5177;&#x7121;&#x7591;&#x5927;&#x5927;&#x589E;&#x5F37;&#x4E86;&#x7CFB;&#x7D71;&#x7684;&#x529F;&#x80FD;&#x548C;&#x4FBF;&#x5229;&#x6027;&#xFF0C;&#x7121;&#x8AD6;&#x662F;&#x91DD;&#x5C0D;&#x65E5;&#x5E38;&#x4F7F;&#x7528;&#x7684;&#x547D;&#x4EE4;&#x5217;&#x5DE5;&#x5177;&#x3001;&#x7CFB;&#x7D71;&#x7684;&#x81EA;&#x52D5;&#x5316;&#x7DAD;&#x8B77;&#xFF0C;&#x9084;&#x662F;&#x63D0;&#x5347;&#x6027;&#x80FD;&#x7684;&#x512A;&#x5316;&#xFF0C;&#x90FD;&#x80FD;&#x8B93;&#x60A8;&#x7684;unRAID&#x7CFB;&#x7D71;&#x66F4;&#x52A0;&#x9AD8;&#x6548;&#x548C;&#x7A69;&#x5B9A;&#x3002;&#x7121;&#x8AD6;&#x662F;&#x525B;&#x5165;&#x9580;&#x7684;&#x65B0;&#x624B;&#xFF0C;&#x9084;&#x662F;&#x5DF2;&#x7D93;&#x5728;unRAID&#x4E0A;&#x6709;&#x8C50;&#x5BCC;&#x7D93;&#x9A57;&#x7684;&#x7528;&#x6236;&#xFF0C;&#x9019;&#x4E9B;&#x63D2;&#x4EF6;&#x90FD;&#x5C07;&#x8B93;&#x4F7F;&#x7528;&#x9AD4;&#x9A57;&#x5927;&#x70BA;&#x63D0;&#x5347;&#x3002;</p>
<p>&#x7576;&#x7136;unRAID&#x7684;&#x63D2;&#x4EF6;&#x751F;&#x614B;&#x7CFB;&#x7D71;&#x9060;&#x4E0D;&#x6B62;&#x65BC;&#x6B64;&#xFF0C;&#x5F8C;&#x7E8C;&#x9084;&#x6703;&#x6DF1;&#x5165;&#x63A2;&#x8A0E;&#x66F4;&#x591A;&#x5BE6;&#x7528;&#x7684;&#x63D2;&#x4EF6;&#x3001;&#x66F4;&#x597D;&#x5730;&#x5229;&#x7528;unRAID&#x7684;&#x5F37;&#x5927;&#x529F;&#x80FD;&#xFF0C;&#x656C;&#x8ACB;&#x671F;&#x5F85;&#x4E0B;&#x4E00;&#x7BC7;&#x7684;&#x8A73;&#x7D30;&#x4ECB;&#x7D39;&#x3002;</p>]]></content:encoded></item><item><title><![CDATA[unRAID Server Note 01]]></title><description><![CDATA[<h1 id="unraidflexible-powerful-home-server-%E8%A8%AD%E5%AE%9A%E7%AF%87">unRAID - Flexible &amp; Powerful Home Server &#x8A2D;&#x5B9A;&#x7BC7;</h1>
<p>unRAID&#x662F;&#x4E00;&#x6B3E;&#x5C08;&#x70BA;&#x5BB6;&#x5EAD;&#x548C;&#x5C0F;&#x578B;&#x8FA6;&#x516C;&#x5BA4;&#x8A2D;&#x8A08;&#x7684;NAS&#x4F5C;&#x696D;&#x7CFB;&#x7D71;&#xFF0C;&#x5B83;&#x57FA;&#x65BC;Linux&#x6838;&#x5FC3;&#xFF0C;&#x63D0;&#x4F9B;&#x4E86;&#x4E00;&#x500B;&#x9748;&#x6D3B;&#x4E14;&#x6613;&#x65BC;</p>]]></description><link>https://ghost.augustushsu.com/unraid-server-note-01/</link><guid isPermaLink="false">66f11c43bd8ad405433c38b7</guid><category><![CDATA[Unraid-Server-Note]]></category><dc:creator><![CDATA[AugustusHsu]]></dc:creator><pubDate>Sun, 06 Oct 2024 12:00:14 GMT</pubDate><media:content url="https://ghost.augustushsu.com/content/images/2024/09/unraid-server-note-01-1.png" medium="image"/><content:encoded><![CDATA[<h1 id="unraidflexible-powerful-home-server-%E8%A8%AD%E5%AE%9A%E7%AF%87">unRAID - Flexible &amp; Powerful Home Server &#x8A2D;&#x5B9A;&#x7BC7;</h1>
<img src="https://ghost.augustushsu.com/content/images/2024/09/unraid-server-note-01-1.png" alt="unRAID Server Note 01"><p>unRAID&#x662F;&#x4E00;&#x6B3E;&#x5C08;&#x70BA;&#x5BB6;&#x5EAD;&#x548C;&#x5C0F;&#x578B;&#x8FA6;&#x516C;&#x5BA4;&#x8A2D;&#x8A08;&#x7684;NAS&#x4F5C;&#x696D;&#x7CFB;&#x7D71;&#xFF0C;&#x5B83;&#x57FA;&#x65BC;Linux&#x6838;&#x5FC3;&#xFF0C;&#x63D0;&#x4F9B;&#x4E86;&#x4E00;&#x500B;&#x9748;&#x6D3B;&#x4E14;&#x6613;&#x65BC;&#x64F4;&#x5145;&#x7684;&#x5132;&#x5B58;&#x89E3;&#x6C7A;&#x65B9;&#x6848;&#x3002;&#x8207;&#x50B3;&#x7D71;&#x7684;RAID&#x7CFB;&#x7D71;&#x4E0D;&#x540C;&#xFF0C;unRAID&#x5141;&#x8A31;&#x4F60;&#x4F7F;&#x7528;&#x4E0D;&#x540C;&#x5BB9;&#x91CF;&#x548C;&#x54C1;&#x724C;&#x7684;&#x786C;&#x789F;&#xFF0C;&#x7D44;&#x6210;&#x4E00;&#x500B;&#x5F48;&#x6027;&#x7684;&#x5132;&#x5B58;&#x6C60;&#xFF0C;&#x4E26;&#x901A;&#x904E;&#x5947;&#x5076;&#x6821;&#x9A57;&#xFF08;Parity&#xFF09;&#x6A5F;&#x5236;&#x63D0;&#x4F9B;&#x6578;&#x64DA;&#x4FDD;&#x8B77;&#xFF0C;&#x9019;&#x5C0D;&#x65BC;&#x5BB6;&#x4E2D;&#x6709;&#x591A;&#x9846;&#x4E0D;&#x540C;&#x786C;&#x789F;&#x7684;&#x4F7F;&#x7528;&#x8005;&#x7279;&#x5225;&#x53CB;&#x5584;&#x3002;</p>
<p>&#x9664;&#x4E86;&#x5F37;&#x5927;&#x7684;&#x5132;&#x5B58;&#x529F;&#x80FD;&#xFF0C;unRAID&#x9084;&#x652F;&#x63F4;&#x865B;&#x64EC;&#x5316;&#x548C;Docker&#x5BB9;&#x5668;&#xFF0C;&#x9019;&#x610F;&#x5473;&#x8457;&#x4F60;&#x53EF;&#x4EE5;&#x5728;&#x540C;&#x4E00;&#x53F0;&#x6A5F;&#x5668;&#x4E0A;&#x904B;&#x884C;&#x591A;&#x500B;&#x865B;&#x64EC;&#x6A5F;&#x6216;&#x61C9;&#x7528;&#x7A0B;&#x5F0F;&#xFF0C;&#x6EFF;&#x8DB3;&#x5404;&#x7A2E;&#x9700;&#x6C42;&#x3002;&#x7121;&#x8AD6;&#x662F;&#x642D;&#x5EFA;&#x5A92;&#x9AD4;&#x4F3A;&#x670D;&#x5668;&#x3001;&#x958B;&#x767C;&#x74B0;&#x5883;&#xFF0C;&#x9084;&#x662F;&#x5176;&#x4ED6;&#x670D;&#x52D9;&#xFF0C;&#x90FD;&#x80FD;&#x8F15;&#x9B06;&#x5BE6;&#x73FE;&#x3002;</p>
<p>&#x672C;&#x6587;&#x4E3B;&#x8981;&#x5728;&#x8A18;&#x9304;unRAID&#x4E0A;&#x5B89;&#x88DD;&#x4E86;&#x4EC0;&#x9EBC;&#x5BE6;&#x7528;&#x7684;&#x5DE5;&#x5177;&#x548C;&#x52A0;&#x4E0A;&#x4E86;&#x54EA;&#x4E9B;&#x8A2D;&#x5B9A;&#xFF0C;&#x9019;&#x4E9B;&#x90FD;&#x662F;&#x6211;&#x5728;&#x4F7F;&#x7528;&#x904E;&#x7A0B;&#x4E2D;&#x89BA;&#x5F97;&#x975E;&#x5E38;&#x6709;&#x5E6B;&#x52A9;&#x7684;&#xFF0C;&#x5728;&#x521D;&#x6B21;&#x5B89;&#x88DD;unRAID&#x5F8C;&#xFF0C;&#x6709;&#x4E00;&#x4E9B;&#x91CD;&#x8981;&#x7684;&#x8A2D;&#x5B9A;&#xFF0C;&#x53EF;&#x4EE5;&#x63D0;&#x5347;&#x7CFB;&#x7D71;&#x7684;&#x529F;&#x80FD;&#x3001;&#x7A69;&#x5B9A;&#x6027;&#x548C;&#x5B89;&#x5168;&#x6027;&#x3002;</p>
<h2 id="%E7%B6%B2%E8%B7%AF%E8%88%87%E5%AE%89%E5%85%A8%E8%A8%AD%E5%AE%9A">&#x7DB2;&#x8DEF;&#x8207;&#x5B89;&#x5168;&#x8A2D;&#x5B9A;</h2>
<p>&#x70BA;&#x4E86;&#x65B9;&#x4FBF;&#x7BA1;&#x7406;&#x548C;&#x9023;&#x63A5;&#xFF0C;&#x53EF;&#x4EE5;&#x70BA;unRAID&#x4F3A;&#x670D;&#x5668;&#x8A2D;&#x5B9A;&#x4E86;&#x4E00;&#x500B;&#x56FA;&#x5B9A;&#x7684;IP&#x5730;&#x5740;&#xFF0C;&#x907F;&#x514D;&#x6BCF;&#x6B21;&#x91CD;&#x65B0;&#x555F;&#x52D5;&#x8DEF;&#x7531;&#x5668;&#x6216;&#x4F3A;&#x670D;&#x5668;&#x6642;&#xFF0C;IP&#x5730;&#x5740;&#x6539;&#x8B8A;&#x5E36;&#x4F86;&#x7684;&#x4E0D;&#x4FBF;&#x3002;&#x53EF;&#x4EE5;&#x5728;unRAID&#x7684;&#x300C;SETTINGS&#x300D;&gt;&#x300C;Network Settings&#x300D;&#x4E2D;&#xFF0C;&#x5C07;IP&#x5730;&#x5740;&#x5F9E;&#x81EA;&#x52D5;&#x53D6;&#x5F97;&#x6539;&#x70BA;&#x624B;&#x52D5;&#x8A2D;&#x5B9A;&#x3002;</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-1.png" class="kg-image" alt="unRAID Server Note 01" loading="lazy" width="1537" height="863" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-1.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2024/09/image-1.png 1000w, https://ghost.augustushsu.com/content/images/2024/09/image-1.png 1537w" sizes="(min-width: 720px) 720px"></figure>
<h2 id="%E5%BB%BA%E7%AB%8B%E4%BD%BF%E7%94%A8%E8%80%85%E5%B8%B3%E6%88%B6%E8%88%87%E6%AC%8A%E9%99%90">&#x5EFA;&#x7ACB;&#x4F7F;&#x7528;&#x8005;&#x5E33;&#x6236;&#x8207;&#x6B0A;&#x9650;</h2>
<p>unRAID&#x5141;&#x8A31;&#x5EFA;&#x7ACB;&#x591A;&#x500B;&#x4F7F;&#x7528;&#x8005;&#x5E33;&#x6236;&#xFF0C;&#x4E26;&#x70BA;&#x4E0D;&#x540C;&#x7684;&#x5171;&#x4EAB;&#x8CC7;&#x6599;&#x593E;&#x8A2D;&#x5B9A;&#x8B80;&#x5BEB;&#x6B0A;&#x9650;&#x3002;&#x53EF;&#x4EE5;&#x70BA;&#x5BB6;&#x4EBA;&#x548C;&#x670B;&#x53CB;&#x5EFA;&#x7ACB;&#x5404;&#x81EA;&#x7684;&#x5E33;&#x6236;&#xFF0C;&#x78BA;&#x4FDD;&#x79C1;&#x4EBA;&#x8CC7;&#x6599;&#x7684;&#x5B89;&#x5168;&#x6027;&#xFF0C;&#x540C;&#x6642;&#x65B9;&#x4FBF;&#x5171;&#x4EAB;&#x516C;&#x5171;&#x8CC7;&#x6E90;&#xFF0C;&#x53EF;&#x4EE5;&#x5728;&#x300C;USERS&#x300D;&gt;&#x300C;ADD USER&#x300D;&#x4E2D;&#x65B0;&#x589E;&#x4F7F;&#x7528;&#x8005;&#x3002;</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-3.png" class="kg-image" alt="unRAID Server Note 01" loading="lazy" width="1160" height="977" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-3.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2024/09/image-3.png 1000w, https://ghost.augustushsu.com/content/images/2024/09/image-3.png 1160w" sizes="(min-width: 720px) 720px"></figure>
<h2 id="%E9%85%8D%E7%BD%AE%E9%80%9A%E7%9F%A5%E8%A8%AD%E5%AE%9A">&#x914D;&#x7F6E;&#x901A;&#x77E5;&#x8A2D;&#x5B9A;</h2>
<p>&#x53EF;&#x4EE5;&#x5728;&#x300C;SETTINGS&#x300D;&gt;&#x300C;Notification Settings&#x300D;&#x4E2D;&#x8A2D;&#x5B9A;&#x96FB;&#x5B50;&#x90F5;&#x4EF6;&#x6216;&#x624B;&#x6A5F;APP&#x901A;&#x77E5;&#xFF0C;&#x7576;&#x7CFB;&#x7D71;&#x767C;&#x751F;&#x932F;&#x8AA4;&#x3001;&#x786C;&#x789F;&#x6545;&#x969C;&#x6216;&#x9700;&#x8981;&#x6CE8;&#x610F;&#x7684;&#x4E8B;&#x4EF6;&#x6642;&#xFF0C;&#x6703;&#x5373;&#x6642;&#x6536;&#x5230;&#x63D0;&#x9192;&#xFF0C;&#x5176;&#x4E2D;&#x53EF;&#x4EE5;&#x8A2D;&#x5B9A;SMTP&#x767C;&#x9001;&#x90F5;&#x4EF6;&#x7684;&#x901A;&#x77E5;&#x8A0A;&#x606F;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-4.png" class="kg-image" alt="unRAID Server Note 01" loading="lazy" width="1072" height="853" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-4.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2024/09/image-4.png 1000w, https://ghost.augustushsu.com/content/images/2024/09/image-4.png 1072w" sizes="(min-width: 720px) 720px"></figure>
<p>&#x4E5F;&#x53EF;&#x4EE5;&#x7D81;&#x5B9A;Discord&#x3001;Slack&#x3001;Telegram&#x7B49;&#x7B49;&#x7684;APP&#x4F86;&#x901A;&#x77E5;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-5.png" class="kg-image" alt="unRAID Server Note 01" loading="lazy" width="1074" height="360" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-5.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2024/09/image-5.png 1000w, https://ghost.augustushsu.com/content/images/2024/09/image-5.png 1074w" sizes="(min-width: 720px) 720px"></figure>
<h2 id="%E8%A8%AD%E5%AE%9Aparity%E7%A1%AC%E7%A2%9F">&#x8A2D;&#x5B9A;Parity&#x786C;&#x789F;</h2>
<p>&#x70BA;&#x4E86;&#x4FDD;&#x8B77;&#x8CC7;&#x6599;&#x5B89;&#x5168;&#xFF0C;&#x53EF;&#x4EE5;&#x6DFB;&#x52A0;&#x4E86;Parity&#x786C;&#x789F;&#xFF0C;&#x6BCF;&#x589E;&#x52A0;&#x4E00;&#x9846;Parity&#x786C;&#x789F;&#xFF0C;&#x53EF;&#x4EE5;&#x9810;&#x9632;&#x4E00;&#x9846;&#x8CC7;&#x6599;&#x786C;&#x789F;&#x6545;&#x969C;&#x8CC7;&#x6599;&#x4E5F;&#x4E0D;&#x6703;&#x907A;&#x5931;&#x3002;&#x8981;&#x6CE8;&#x610F;&#x7684;&#x662F;Parity&#x786C;&#x789F;&#x5BB9;&#x91CF;&#x8981;&#x5927;&#x65BC;&#x7B49;&#x65BC;&#x5176;&#x4ED6;&#x7684;&#x8CC7;&#x6599;&#x786C;&#x789F;&#xFF0C;&#x4EE5;&#x8986;&#x84CB;&#x9663;&#x5217;&#x4E2D;&#x6240;&#x6709;&#x786C;&#x789F;&#x7684;&#x5BB9;&#x91CF;&#x3002;</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-6.png" class="kg-image" alt="unRAID Server Note 01" loading="lazy" width="640" height="287" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-6.png 600w, https://ghost.augustushsu.com/content/images/2024/09/image-6.png 640w"></figure>
<h2 id="%E9%85%8D%E7%BD%AEcache%E5%BF%AB%E5%8F%96%E7%9B%A4">&#x914D;&#x7F6E;Cache&#x5FEB;&#x53D6;&#x76E4;</h2>
<p>&#x4F7F;&#x7528;&#x4E86;&#x4E00;&#x9846;SSD&#x4F5C;&#x70BA;Cache&#x5FEB;&#x53D6;&#x76E4;&#xFF0C;&#x53EF;&#x4EE5;&#x52A0;&#x901F;&#x8CC7;&#x6599;&#x7684;&#x8B80;&#x5BEB;&#x901F;&#x5EA6;&#xFF0C;&#x9019;&#x5C0D;&#x65BC;&#x983B;&#x7E41;&#x5B58;&#x53D6;&#x548C;&#x5C0F;&#x6A94;&#x6848;&#x7684;&#x64CD;&#x4F5C;&#x7279;&#x5225;&#x6709;&#x6548;&#xFF0C;&#x53EF;&#x4EE5;&#x5728;&#x300C;MAIN&#x300D;&#x7684;&#x300C;Devices&#x300D;&#x90E8;&#x5206;&#x6DFB;&#x52A0;Cache&#x76E4;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-7.png" class="kg-image" alt="unRAID Server Note 01" loading="lazy" width="663" height="135" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-7.png 600w, https://ghost.augustushsu.com/content/images/2024/09/image-7.png 663w"></figure>
<p>&#x4E26;&#x5728;&#x300C;SHARES&#x300D;&#x7684;&#x8A2D;&#x5B9A;&#x4E2D;&#x300C;Primary storage&#x300D;&#x555F;&#x7528;Cache&#x529F;&#x80FD;&#xFF0C;&#x555F;&#x52D5;&#x6703;&#x512A;&#x5148;&#x5C07;&#x6A94;&#x6848;&#x5B58;&#x5728;Cache&#x7684;&#x786C;&#x789F;&#x4E2D;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-8.png" class="kg-image" alt="unRAID Server Note 01" loading="lazy" width="1862" height="923" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-8.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2024/09/image-8.png 1000w, https://ghost.augustushsu.com/content/images/size/w1600/2024/09/image-8.png 1600w, https://ghost.augustushsu.com/content/images/2024/09/image-8.png 1862w" sizes="(min-width: 720px) 720px"></figure>
<ol><li><strong>Primary storage (&#x4E3B;&#x5132;&#x5B58;&#x7A7A;&#x9593;): </strong>&#x9867;&#x540D;&#x601D;&#x7FA9;&#xFF0C;&#x662F;&#x5EFA;&#x7ACB;&#x65B0;&#x6A94;&#x6848;&#x548C;&#x65B0;&#x8CC7;&#x6599;&#x593E;&#x6642;&#x6240;&#x4F7F;&#x7528;&#x7684;&#x5132;&#x5B58;&#x6C60;&#x3002;&#x4E3B;&#x5132;&#x5B58;&#x7A7A;&#x9593;&#x53EA;&#x6709;&#x5169;&#x7A2E;&#x985E;&#x578B;&#x7684;&#x9078;&#x64C7;&#x2014; <code>Array</code>&#x548C;<code>Cache</code>&#xFF1A;</li></ol>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-38.png" class="kg-image" alt="unRAID Server Note 01" loading="lazy" width="672" height="92" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-38.png 600w, https://ghost.augustushsu.com/content/images/2024/09/image-38.png 672w"></figure>
<ol start="2"><li><strong>Secondary storage (&#x8F14;&#x52A9;&#x5132;&#x5B58;): </strong>&#x53EA;&#x6709;&#x5728;&#x4E3B;&#x5132;&#x5B58;&#x7A7A;&#x9593;&#x9078;&#x64C7;&#x4E86;&#x5FEB;&#x53D6;&#x6C60;&#x4E4B;&#x5F8C;&#xFF0C;&#x8F14;&#x52A9;&#x5132;&#x5B58;&#x624D;&#x53EF;&#x80FD;&#x9032;&#x884C;&#x914D;&#x7F6E;&#xFF0C;&#x4E26;&#x4E14;&#x53EA;&#x6709;&#x5169;&#x500B;&#x56FA;&#x5B9A;&#x9078;&#x9805;&#xFF0D;<code>None</code>/ <code>Array</code>&#x3002;</li></ol>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-40.png" class="kg-image" alt="unRAID Server Note 01" loading="lazy" width="837" height="210" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-40.png 600w, https://ghost.augustushsu.com/content/images/2024/09/image-40.png 837w" sizes="(min-width: 720px) 720px"></figure>
<p>&#x5982;&#x679C;&#x4F60;&#x5728;&#x4E3B;&#x5132;&#x5B58;&#x7A7A;&#x9593;&#x9078;&#x64C7;&#x4E86;<code>Array</code>&#xFF0C;&#x90A3;&#x9EBC;&#x4E5F;&#x5C31;&#x7B49;&#x65BC;&#x4E0D;&#x53BB;&#x4F7F;&#x7528;<code>Cache</code> (&#x6B64;&#x6642;Secondary storage&#x4E0D;&#x53EF;&#x8A2D;&#x5B9A;&#xFF0C;Array&#x70BA;&#x7070;&#x8272;&#x7121;&#x6CD5;&#x9078;&#x64C7;) : </p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-42.png" class="kg-image" alt="unRAID Server Note 01" loading="lazy" width="823" height="328" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-42.png 600w, https://ghost.augustushsu.com/content/images/2024/09/image-42.png 823w" sizes="(min-width: 720px) 720px"></figure>
<p>Mover&#x53EF;&#x4EE5;&#x6307;&#x5B9A;&#x8981;&#x5F9E;<code>Array</code> &gt; <code>Cache</code> &#x6216;&#x662F;<code>Cache</code>  &gt; <code>Array</code> :</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-44.png" class="kg-image" alt="unRAID Server Note 01" loading="lazy" width="679" height="94" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-44.png 600w, https://ghost.augustushsu.com/content/images/2024/09/image-44.png 679w"></figure>
<p>&#x5728;&#x300C;SETTINGS&#x300D;&gt;&#x300C;Scheduler&#x300D;&#x53EF;&#x4EE5;&#x8A2D;&#x5B9A;&#x5C07;&#x8CC7;&#x6599;&#x5F9E;Cache&#x8F49;&#x79FB;&#x5230;&#x8CC7;&#x6599;&#x786C;&#x789F;&#x7684;&#x5B9A;&#x671F;&#x57F7;&#x884C;&#x6642;&#x9593;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-9.png" class="kg-image" alt="unRAID Server Note 01" loading="lazy" width="956" height="408" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-9.png 600w, https://ghost.augustushsu.com/content/images/2024/09/image-9.png 956w" sizes="(min-width: 720px) 720px"></figure>
<h2 id="%E8%A8%AD%E5%AE%9A%E6%99%82%E5%8D%80">&#x8A2D;&#x5B9A;&#x6642;&#x5340;</h2>
<p>&#x5728;&#x300C;SETTINGS&#x300D;&gt;&#x300C;Date and Time&#x300D;&#x8A2D;&#x5B9A;&#x81EA;&#x5DF1;&#x7684;&#x6642;&#x5340;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-10.png" class="kg-image" alt="unRAID Server Note 01" loading="lazy" width="1076" height="573" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-10.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2024/09/image-10.png 1000w, https://ghost.augustushsu.com/content/images/2024/09/image-10.png 1076w" sizes="(min-width: 720px) 720px"></figure>
<h2 id="parity-check">Parity Check</h2>
<p>&#x5728;&#x300C;SETTINGS&#x300D;&gt;&#x300C;Scheduler&#x300D;&#x4E2D;&#x8A2D;&#x5B9A;&#x5B9A;&#x671F;&#x5947;&#x5076;&#x6821;&#x9A57;&#x7684;&#x6642;&#x9593;&#xFF0C;&#x6211;&#x662F;&#x7FD2;&#x6163;&#x5728;&#x6BCF;&#x500B;&#x6708;&#x7684;&#x7B2C;&#x4E00;&#x5929;&#x534A;&#x591C;3&#x9EDE;30&#x5206;&#x958B;&#x59CB;&#x5947;&#x5076;&#x6821;&#x9A57;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-13.png" class="kg-image" alt="unRAID Server Note 01" loading="lazy" width="916" height="500" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-13.png 600w, https://ghost.augustushsu.com/content/images/2024/09/image-13.png 916w" sizes="(min-width: 720px) 720px"></figure>
<h2 id="%E9%96%8B%E5%95%9Flog">&#x958B;&#x555F;Log</h2>
<p>&#x5728;&#x7BA1;&#x7406;&#x548C;&#x7DAD;&#x8B77;unRAID&#x4F3A;&#x670D;&#x5668;&#x7684;&#x904E;&#x7A0B;&#x4E2D;&#xFF0C;Syslog&#x662F;&#x975E;&#x5E38;&#x91CD;&#x8981;&#x7684;&#x5DE5;&#x5177;&#x3002;&#x5B83;&#x53EF;&#x4EE5;&#x5E6B;&#x52A9;&#x60A8;&#x76E3;&#x63A7;&#x7CFB;&#x7D71;&#x904B;&#x884C;&#x60C5;&#x6CC1;&#x3001;&#x8A3A;&#x65B7;&#x554F;&#x984C;&#x4EE5;&#x53CA;&#x8FFD;&#x8E64;&#x7570;&#x5E38;&#x4E8B;&#x4EF6;&#x3002;&#x901A;&#x904E;&#x555F;&#x7528;Syslog Server&#xFF0C;&#x60A8;&#x53EF;&#x4EE5;&#x5C07;&#x7CFB;&#x7D71;&#x65E5;&#x8A8C;&#x96C6;&#x4E2D;&#x4FDD;&#x5B58;&#xFF0C;&#x65B9;&#x4FBF;&#x65E5;&#x5F8C;&#x67E5;&#x770B;&#x548C;&#x5206;&#x6790;&#x3002;</p>
<p>&#x5728;&#x300C;SETTINGS&#x300D;&gt;&#x300C;Syslog Server&#x300D;&#x4E2D;&#x53EF;&#x4EE5;&#x958B;&#x555F;Syslog&#x7684;&#x8A2D;&#x5B9A;&#xFF0C;&#x5176;&#x4ED6;&#x8A2D;&#x5B9A;&#x65B9;&#x9762;&#x53EF;&#x4EE5;&#x53C3;&#x7167;&#x4E0B;&#x5716;&#xFF0C;&#x8981;&#x6CE8;&#x610F;&#x7684;&#x662F;Remote syslog server&#x8981;&#x8A2D;&#x5B9A;&#x70BA;&#x672C;&#x6A5F;&#x7684;ip:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2024/09/image-31.png" class="kg-image" alt="unRAID Server Note 01" loading="lazy" width="1131" height="495" srcset="https://ghost.augustushsu.com/content/images/size/w600/2024/09/image-31.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2024/09/image-31.png 1000w, https://ghost.augustushsu.com/content/images/2024/09/image-31.png 1131w" sizes="(min-width: 720px) 720px"></figure>
<h2 id="%E7%B5%90%E8%AB%96">&#x7D50;&#x8AD6;</h2>
<p>&#x901A;&#x904E;&#x9019;&#x4E9B;&#x8A2D;&#x5B9A;&#xFF0C;unRAID&#x4E0D;&#x50C5;&#x53EF;&#x4EE5;&#x4F5C;&#x70BA;&#x5F37;&#x5927;&#x7684; NAS &#x4F3A;&#x670D;&#x5668;&#xFF0C;&#x9084;&#x80FD;&#x6210;&#x70BA;&#x4E00;&#x500B;&#x9748;&#x6D3B;&#x7684;&#x5BB6;&#x5EAD;&#x4F3A;&#x670D;&#x5668;&#x5E73;&#x53F0;&#xFF0C;&#x6EFF;&#x8DB3;&#x591A;&#x6A23;&#x5316;&#x7684;&#x9700;&#x6C42;&#x3002;&#x5F9E;&#x7DB2;&#x8DEF;&#x8A2D;&#x5B9A;&#x3001;&#x4F7F;&#x7528;&#x8005;&#x6B0A;&#x9650;&#x7BA1;&#x7406;&#x5230;&#x91CD;&#x8981;&#x7684; Parity &#x786C;&#x789F;&#x8207; Cache &#x5FEB;&#x53D6;&#x76E4;&#x914D;&#x7F6E;&#xFF0C;&#x9019;&#x4E9B;&#x6B65;&#x9A5F;&#x4E0D;&#x50C5;&#x63D0;&#x5347;&#x4E86;&#x7CFB;&#x7D71;&#x7684;&#x6027;&#x80FD;&#x548C;&#x6548;&#x7387;&#xFF0C;&#x4E5F;&#x589E;&#x5F37;&#x4E86;&#x8CC7;&#x6599;&#x7684;&#x4FDD;&#x8B77;&#x6027;&#x548C;&#x7BA1;&#x7406;&#x4FBF;&#x5229;&#x6027;&#x3002;&#x6B64;&#x5916;&#xFF0C;&#x901A;&#x904E;&#x555F;&#x7528; Syslog &#x4F3A;&#x670D;&#x5668;&#x548C;&#x8A2D;&#x7F6E;&#x901A;&#x77E5;&#x529F;&#x80FD;&#xFF0C;&#x60A8;&#x53EF;&#x4EE5;&#x96A8;&#x6642;&#x638C;&#x63E1;&#x7CFB;&#x7D71;&#x904B;&#x884C;&#x72C0;&#x6CC1;&#x4E26;&#x8FC5;&#x901F;&#x8655;&#x7406;&#x6F5B;&#x5728;&#x554F;&#x984C;&#x3002;&#x9019;&#x4E9B;&#x8A2D;&#x5B9A;&#x5C07;&#x4F7F;unRAID&#x6210;&#x70BA;&#x4E00;&#x500B;&#x7A69;&#x5B9A;&#x3001;&#x9AD8;&#x6548;&#x4E14;&#x53EF;&#x9760;&#x7684;&#x5BB6;&#x5EAD;&#x4F3A;&#x670D;&#x5668;&#x5E73;&#x53F0;&#xFF0C;&#x4E0D;&#x50C5;&#x8B93;&#x60A8;&#x66F4;&#x5B89;&#x5FC3;&#xFF0C;&#x4E5F;&#x80FD;&#x8B93;&#x5BB6;&#x4EBA;&#x548C;&#x670B;&#x53CB;&#x8F15;&#x9B06;&#x5171;&#x4EAB;&#x8CC7;&#x6E90;&#x8207;&#x670D;&#x52D9;&#x3002;</p>
<p>&#x7121;&#x8AD6;&#x662F;&#x521D;&#x6B21;&#x5B89;&#x88DD;unRAID&#xFF0C;&#x9084;&#x662F;&#x9032;&#x884C;&#x5F8C;&#x7E8C;&#x512A;&#x5316;&#xFF0C;&#x9019;&#x4E9B;&#x5BE6;&#x7528;&#x7684;&#x5DE5;&#x5177;&#x548C;&#x8A2D;&#x5B9A;&#x90FD;&#x5C07;&#x986F;&#x8457;&#x63D0;&#x5347;&#x7CFB;&#x7D71;&#x7684;&#x6574;&#x9AD4;&#x4F7F;&#x7528;&#x9AD4;&#x9A57;&#x3002;&#x5982;&#x679C;&#x4F60;&#x60F3;&#x8981;&#x4E00;&#x500B;&#x7C21;&#x55AE;&#x6613;&#x7528;&#x3001;&#x529F;&#x80FD;&#x5F37;&#x5927;&#x7684;&#x5BB6;&#x7528;&#x4F3A;&#x670D;&#x5668;&#x5E73;&#x53F0;&#xFF0C;unRAID &#x7D55;&#x5C0D;&#x662F;&#x4E0D;&#x932F;&#x7684;&#x9078;&#x64C7;&#xFF01;</p>
<p></p>
<p></p>
<p></p>]]></content:encoded></item><item><title><![CDATA[Python Note 04]]></title><description><![CDATA[<h1 id="python%E7%9A%84debug%E7%A5%9E%E5%99%A8">Python&#x7684;Debug&#x795E;&#x5668;</h1>
<p>&#x5728;&#x65E5;&#x5E38;&#x9664;&#x932F;&#x904E;&#x7A0B;&#x4E2D;&#xFF0C;&#x6211;&#x5011;&#x7D93;&#x5E38;&#x6703;&#x4F7F;&#x7528; <code>print()</code>&#x51FD;&#x6578;&#x67E5;&#x770B;&#x8B8A;&#x6578;&#x5167;&#x5BB9;&#xFF0C;&#x4EE5;&#x78BA;&#x8A8D;&#x7A0B;&#x5F0F;&#x57F7;&#x884C;&#x7684;&#x7D50;&#x679C;&#x662F;&#x5426;&#x5982;&#x9810;&#x671F;&#x3002;&#x7136;&#x800C;&#xFF0C;</p>]]></description><link>https://ghost.augustushsu.com/python-note-04/</link><guid isPermaLink="false">650337bf5677df0593b3872e</guid><category><![CDATA[Python-Note]]></category><dc:creator><![CDATA[AugustusHsu]]></dc:creator><pubDate>Sun, 29 Sep 2024 12:00:55 GMT</pubDate><media:content url="https://ghost.augustushsu.com/content/images/2024/09/python-note04.png" medium="image"/><content:encoded><![CDATA[<h1 id="python%E7%9A%84debug%E7%A5%9E%E5%99%A8">Python&#x7684;Debug&#x795E;&#x5668;</h1>
<img src="https://ghost.augustushsu.com/content/images/2024/09/python-note04.png" alt="Python Note 04"><p>&#x5728;&#x65E5;&#x5E38;&#x9664;&#x932F;&#x904E;&#x7A0B;&#x4E2D;&#xFF0C;&#x6211;&#x5011;&#x7D93;&#x5E38;&#x6703;&#x4F7F;&#x7528; <code>print()</code>&#x51FD;&#x6578;&#x67E5;&#x770B;&#x8B8A;&#x6578;&#x5167;&#x5BB9;&#xFF0C;&#x4EE5;&#x78BA;&#x8A8D;&#x7A0B;&#x5F0F;&#x57F7;&#x884C;&#x7684;&#x7D50;&#x679C;&#x662F;&#x5426;&#x5982;&#x9810;&#x671F;&#x3002;&#x7136;&#x800C;&#xFF0C;&#x9019;&#x6A23;&#x505A;&#x5F80;&#x5F80;&#x9700;&#x8981;&#x82B1;&#x8CBB;&#x5927;&#x91CF;&#x6642;&#x9593;&#x53BB;&#x9010;&#x4E00;&#x6AA2;&#x67E5;&#x8F38;&#x51FA;&#x7684;&#x6B63;&#x78BA;&#x6027;&#x3002;&#x5728; Python &#x4E2D;&#xFF0C;&#x6709;&#x4E00;&#x500B;&#x5167;&#x5EFA;&#x51FD;&#x6578;&#x53EB;&#x505A; <code>breakpoint()</code>&#xFF0C;&#x5C08;&#x9580;&#x7528;&#x65BC;&#x555F;&#x52D5;&#x5075;&#x932F;&#x5668;&#x3002;&#x7576;&#x57F7;&#x884C;&#x5230; <code>breakpoint()</code> &#x6642;&#xFF0C;&#x7A0B;&#x5E8F;&#x6703;&#x66AB;&#x505C;&#xFF0C;&#x4E26;&#x9032;&#x5165;&#x4E00;&#x500B;&#x4E92;&#x52D5;&#x5F0F;&#x7684;&#x8ABF;&#x8A66;&#x74B0;&#x5883;&#x3002;&#x900F;&#x904E;&#x9019;&#x500B;&#x529F;&#x80FD;&#xFF0C;&#x4F60;&#x53EF;&#x4EE5;&#x67E5;&#x770B;&#x8B8A;&#x6578;&#x7684;&#x503C;&#x3001;&#x9010;&#x6B65;&#x57F7;&#x884C;&#x7A0B;&#x5F0F;&#x78BC;&#xFF0C;&#x4EE5;&#x53CA;&#x6709;&#x6548;&#x5730;&#x9032;&#x884C;&#x554F;&#x984C;&#x8ABF;&#x8A66;&#x3002;</p>
<h2 id="breakpoint%E7%9A%84%E4%B8%BB%E8%A6%81%E5%8A%9F%E8%83%BD%EF%BC%9A"><code>breakpoint()</code>&#x7684;&#x4E3B;&#x8981;&#x529F;&#x80FD;&#xFF1A;</h2>
<ol><li><strong>&#x66AB;&#x505C;&#x7A0B;&#x5E8F;&#x57F7;&#x884C;</strong>&#xFF1A;&#x7576;&#x7A0B;&#x5F0F;&#x57F7;&#x884C;&#x5230;<code>breakpoint()</code>&#x6642;&#xFF0C;&#x7A0B;&#x5F0F;&#x6703;&#x66AB;&#x505C;&#xFF0C;&#x9032;&#x5165;&#x5075;&#x932F;&#x5668;&#x3002;</li><li><strong>&#x9032;&#x5165;&#x4E92;&#x52D5;&#x5F0F;&#x8ABF;&#x8A66;&#x74B0;&#x5883;</strong>&#xFF1A;&#x4F60;&#x53EF;&#x4EE5;&#x67E5;&#x770B;&#x76EE;&#x524D;&#x7684;&#x8B8A;&#x6578;&#x3001;&#x57F7;&#x884C;&#x4E0B;&#x4E00;&#x6B65;&#x64CD;&#x4F5C;&#x3001;&#x6AA2;&#x67E5;&#x5806;&#x758A;&#x5E40;&#x7B49;&#x3002;</li><li><strong>&#x8ABF;&#x8A66;&#x7A0B;&#x5F0F;&#x78BC;</strong>&#xFF1A;&#x4F60;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x5075;&#x932F;&#x5668;&#x7684;&#x547D;&#x4EE4;&#xFF08;&#x4F8B;&#x5982;<code>n</code>&#x9032;&#x5165;&#x4E0B;&#x4E00;&#x6B65;&#x3001;<code>c</code>&#x7E7C;&#x7E8C;&#x904B;&#x884C;&#x3001;<code>q</code>&#x9000;&#x51FA;&#x8ABF;&#x8A66;&#x5668;&#x7B49;&#xFF09;&#x4F86;&#x9010;&#x6B65;&#x57F7;&#x884C;&#x7A0B;&#x5F0F;&#x78BC;&#xFF0C;&#x5E6B;&#x52A9;&#x4F60;&#x767C;&#x73FE;&#x554F;&#x984C;&#x3002;</li></ol>
<p><code>breakpoint()</code>&#x5728;Python 3.7 &#x7248;&#x672C;&#x4E2D;&#x88AB;&#x5F15;&#x5165;&#xFF0C;&#x5B83;&#x6703;&#x8ABF;&#x7528;<code>sys.breakpointhook()</code>&#xFF0C;&#x901A;&#x5E38;&#x6703;&#x555F;&#x52D5;&#x9810;&#x8A2D;&#x7684;Python &#x5075;&#x932F;&#x5668;<code>pdb</code>&#x3002;</p>
<h2 id="%E5%B8%B8%E8%A6%8B%E8%AA%BF%E8%A9%A6%E5%99%A8%E5%91%BD%E4%BB%A4%EF%BC%9A">&#x5E38;&#x898B;&#x8ABF;&#x8A66;&#x5668;&#x547D;&#x4EE4;&#xFF1A;</h2>
<ul><li><code>n</code> (next)&#xFF1A;&#x57F7;&#x884C;&#x4E0B;&#x4E00;&#x884C;&#x7A0B;&#x5F0F;&#x78BC;&#x3002;</li><li><code>s</code> (step)&#xFF1A;&#x57F7;&#x884C;&#x4E0B;&#x4E00;&#x884C;&#x7A0B;&#x5F0F;&#x78BC;&#xFF0C;&#x5982;&#x679C;&#x8A72;&#x884C;&#x70BA;&#x51FD;&#x6578;&#x547C;&#x53EB;&#x5247;&#x9032;&#x5165;&#x51FD;&#x6578;&#xFF0C;&#x505C;&#x5728;&#x51FD;&#x6578;&#x7B2C;&#x4E00;&#x884C;&#x3002;</li><li><code>w</code> (where)&#xFF1A;&#x5217;&#x51FA;&#x5F9E;&#x7576;&#x524D;&#x57F7;&#x884C;&#x9EDE;&#x5230;&#x6700;&#x5916;&#x5C64;&#x8ABF;&#x7528;&#x7684;&#x4E00;&#x7CFB;&#x5217;&#x51FD;&#x6578;&#x8ABF;&#x7528;&#x548C;&#x884C;&#x865F;&#x3002;</li><li><code>c</code> (continue)&#xFF1A;&#x7E7C;&#x7E8C;&#x57F7;&#x884C;&#x76F4;&#x5230;&#x9047;&#x5230;&#x4E0B;&#x4E00;&#x500B;&#x65B7;&#x9EDE;&#x6216;&#x7A0B;&#x5F0F;&#x7D50;&#x675F;&#x3002;</li><li><code>q</code> (quit)&#xFF1A;&#x9000;&#x51FA;&#x5075;&#x932F;&#x5668;&#x4E26;&#x7D50;&#x675F;&#x7A0B;&#x5F0F;&#x3002;</li><li><code>p</code> (print)&#xFF1A;&#x5217;&#x5370;&#x8B8A;&#x6578;&#x7684;&#x503C;&#xFF0C;&#x4F8B;&#x5982;<code>p some_variable</code>&#x3002;</li><li><code>l</code> (list)&#xFF1A;&#x5370;&#x51FA;&#x76EE;&#x524D;&#x6240;&#x5728; function/frame&#x4E0A;&#x4E0B; 10 &#x884C;&#x7684;&#x7A0B;&#x5F0F;&#x78BC;&#x3002;</li><li><code>ll</code> (long list)&#xFF1A;&#x5370;&#x51FA;&#x76EE;&#x524D;&#x6240;&#x5728; function/frame &#x7684;&#x6240;&#x6709;&#x7A0B;&#x5F0F;&#x78BC;&#x3002;</li><li><code>r</code> (return)&#xFF1A;&#x7E7C;&#x7E8C;&#x57F7;&#x884C;&#x5230;&#x7576;&#x524D;&#x51FD;&#x6578;&#x8FD4;&#x56DE;&#x70BA;&#x6B62;&#x3002;</li></ul>
<h2 id="%E4%BD%BF%E7%94%A8breakpoint%E7%9A%84%E7%AF%84%E4%BE%8B%EF%BC%9A">&#x4F7F;&#x7528;<code>breakpoint()</code>&#x7684;&#x7BC4;&#x4F8B;&#xFF1A;</h2>
<h3 id="%E9%81%8B%E8%A1%8C%E7%AF%84%E4%BE%8B%EF%BC%9A">&#x904B;&#x884C;&#x7BC4;&#x4F8B;&#xFF1A;</h3>
<pre><code class="language-python">def calculate_area(length, width):
    area = length * width
    breakpoint()
    return area

length = 5
width = 10
area = calculate_area(length, width)
print(f&quot;The area is {area}&quot;)
</code></pre>
<p>&#x7576;&#x7A0B;&#x5F0F;&#x78BC;&#x57F7;&#x884C;&#x5230;<code>breakpoint()</code>&#x6642;&#xFF0C;&#x6703;&#x9032;&#x5165;&#x5075;&#x932F;&#x6A21;&#x5F0F;&#xFF0C;&#x4F60;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x5075;&#x932F;&#x5668;&#x6307;&#x4EE4;&#x4F86;&#x67E5;&#x770B;&#x8B8A;&#x6578;&#x7684;&#x503C;&#x6216;&#x9010;&#x6B65;&#x57F7;&#x884C;&#x7A0B;&#x5F0F;&#x78BC;&#x3002;</p>
<h3 id="%E8%BC%B8%E5%87%BA%E5%9C%A8%E9%80%B2%E5%85%A5%E8%AA%BF%E8%A9%A6%E6%A8%A1%E5%BC%8F%E5%BE%8C%EF%BC%9A"><strong>&#x8F38;&#x51FA;(&#x5728;&#x9032;&#x5165;&#x8ABF;&#x8A66;&#x6A21;&#x5F0F;&#x5F8C;)&#xFF1A;</strong></h3>
<pre><code class="language-css">&gt; &lt;filename&gt;(5)calculate_area()
-&gt; return area
(Pdb) p length
5
(Pdb) p width
10
(Pdb) p area
50
(Pdb) n
(Pdb) w
/media/lukaslu/2E7C3ACF7C3A9217/user_data/Jim/code/MongoDB_MinIO_FastAPI/test.py(8)&lt;module&gt;()
-&gt; area = calculate_area(length, width)
&gt; /media/lukaslu/2E7C3ACF7C3A9217/user_data/Jim/code/MongoDB_MinIO_FastAPI/test.py(4)calculate_area()
-&gt; return area</code></pre>
<p>&#x5728;&#x9019;&#x500B;&#x7BC4;&#x4F8B;&#x4E2D;&#xFF0C;&#x7A0B;&#x5F0F;&#x6703;&#x5728;<code>breakpoint()</code>&#x8655;&#x66AB;&#x505C;&#xFF0C;&#x4F60;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;<code>p</code>&#x6307;&#x4EE4;&#x67E5;&#x770B;&#x8B8A;&#x6578;<code>length</code>&#x3001;<code>width</code>&#x548C;<code>area</code>&#x7684;&#x503C;&#xFF1B;&#x4F7F;&#x7528;<code>n</code>&#x9010;&#x6B65;&#x57F7;&#x884C;&#x7A0B;&#x5F0F;&#x78BC;&#xFF1B;&#x4F7F;&#x7528;<code>w</code>&#x53EF;&#x4EE5;&#x67E5;&#x770B;&#x5F9E;&#x7A0B;&#x5F0F;&#x5165;&#x53E3;&#x5230;&#x7576;&#x524D;&#x4E2D;&#x65B7;&#x9EDE;&#x7684;&#x5B8C;&#x6574;&#x8ABF;&#x7528;&#x68E7;&#xFF0C;&#x7BAD;&#x982D; <code>-&gt;</code> &#x6307;&#x5411;&#x7576;&#x524D;&#x6B63;&#x5728;&#x57F7;&#x884C;&#x7684;&#x884C;&#x3002;</p>
<h2 id="%E5%B0%8F%E6%8A%80%E5%B7%A7">&#x5C0F;&#x6280;&#x5DE7;</h2>
<p>&#x4F7F;&#x7528; <code>breakpoint()</code> &#x7684;&#x4E00;&#x4E9B;&#x5C0F;&#x6280;&#x5DE7;&#x53EF;&#x4EE5;&#x8B93;&#x4F60;&#x7684; Python &#x8ABF;&#x8A66;&#x904E;&#x7A0B;&#x66F4;&#x52A0;&#x9AD8;&#x6548;&#x548C;&#x4FBF;&#x5229;&#x3002;&#x4EE5;&#x4E0B;&#x662F;&#x4E00;&#x4E9B;&#x5BE6;&#x7528;&#x7684;&#x5EFA;&#x8B70;&#xFF1A;</p>
<h3 id="%E6%A2%9D%E4%BB%B6%E6%96%B7%E9%BB%9E"><strong>&#x689D;&#x4EF6;&#x65B7;&#x9EDE;</strong></h3>
<p>&#x4F60;&#x53EF;&#x4EE5;&#x5728; <code>breakpoint()</code> &#x51FD;&#x6578;&#x4E2D;&#x6DFB;&#x52A0;&#x689D;&#x4EF6;&#xFF0C;&#x53EA;&#x6709;&#x7576;&#x689D;&#x4EF6;&#x70BA;&#x771F;&#x6642;&#xFF0C;&#x624D;&#x6703;&#x89F8;&#x767C;&#x65B7;&#x9EDE;&#x3002;&#x9019;&#x5728;&#x8655;&#x7406;&#x5FAA;&#x74B0;&#x6216;&#x689D;&#x4EF6;&#x8A9E;&#x53E5;&#x4E2D;&#x7279;&#x5225;&#x6709;&#x7528;&#x3002;</p>
<pre><code class="language-python">for i in range(100):
    if i == 50:
        breakpoint()  # &#x53EA;&#x5728; i &#x7B49;&#x65BC; 50 &#x6642;&#x66AB;&#x505C;
</code></pre>
<h3 id="%E5%8B%95%E6%85%8B%E8%A8%AD%E7%BD%AE%E5%92%8C%E7%A7%BB%E9%99%A4%E6%96%B7%E9%BB%9E"><strong>&#x52D5;&#x614B;&#x8A2D;&#x7F6E;&#x548C;&#x79FB;&#x9664;&#x65B7;&#x9EDE;</strong></h3>
<p>&#x901A;&#x904E;&#x7DE8;&#x7A0B;&#x65B9;&#x5F0F;&#x8A2D;&#x7F6E;&#x548C;&#x79FB;&#x9664;&#x65B7;&#x9EDE;&#xFF0C;&#x53EF;&#x4EE5;&#x6839;&#x64DA;&#x904B;&#x884C;&#x6642;&#x6578;&#x64DA;&#x6216;&#x689D;&#x4EF6;&#x52D5;&#x614B;&#x5730;&#x6539;&#x8B8A;&#x8ABF;&#x8A66;&#x7B56;&#x7565;&#x3002;</p>
<pre><code class="language-python">if some_condition:
    breakpoint()  # &#x52D5;&#x614B;&#x8A2D;&#x7F6E;&#x65B7;&#x9EDE;
</code></pre>
<h3 id="%E6%95%B4%E5%90%88%E6%97%A5%E8%AA%8C"><strong>&#x6574;&#x5408;&#x65E5;&#x8A8C;</strong></h3>
<p>&#x4F7F;&#x7528; <code>breakpoint()</code> &#x6642;&#xFF0C;&#x8003;&#x616E;&#x5728;&#x9032;&#x5165;&#x8ABF;&#x8A66;&#x5668;&#x524D;&#x5F8C;&#x6DFB;&#x52A0;&#x65E5;&#x8A8C;&#x8A9E;&#x53E5;&#xFF0C;&#x9019;&#x6A23;&#x53EF;&#x4EE5;&#x5728;&#x4E0D;&#x9032;&#x5165;&#x8ABF;&#x8A66;&#x5668;&#x7684;&#x60C5;&#x6CC1;&#x4E0B;&#x8FFD;&#x8E64;&#x7A0B;&#x5F0F;&#x7684;&#x904B;&#x884C;&#x72C0;&#x614B;&#x3002;</p>
<pre><code class="language-python">logging.debug(&apos;About to hit breakpoint&apos;)
breakpoint()
logging.debug(&apos;Resuming from breakpoint&apos;)</code></pre>
<h3 id="%E8%87%AA%E5%AE%9A%E7%BE%A9-sysbreakpointhook"><strong>&#x81EA;&#x5B9A;&#x7FA9; <code>sys.breakpointhook</code></strong></h3>
<p>&#x4F60;&#x53EF;&#x4EE5;&#x81EA;&#x5B9A;&#x7FA9; <code>breakpoint()</code> &#x7684;&#x884C;&#x70BA;&#xFF0C;&#x901A;&#x904E;&#x8A2D;&#x7F6E; <code>sys.breakpointhook</code>&#x3002;&#x9019;&#x5141;&#x8A31;&#x4F60;&#x5728;&#x89F8;&#x767C;&#x65B7;&#x9EDE;&#x6642;&#x57F7;&#x884C;&#x81EA;&#x5B9A;&#x7FA9;&#x4EE3;&#x78BC;&#x6216;&#x8ABF;&#x7528;&#x5176;&#x4ED6;&#x8ABF;&#x8A66;&#x5668;&#xFF0C;&#x5982; <code>ipdb</code>&#xFF0C;&#x63D0;&#x4F9B;&#x4E86; <code>pdb</code> &#x7684;&#x6240;&#x6709;&#x529F;&#x80FD;&#xFF0C;&#x540C;&#x6642;&#x589E;&#x52A0;&#x4E86;&#x8A9E;&#x6CD5;&#x9AD8;&#x4EAE;&#x3001;Tab &#x88DC;&#x5168;&#x548C;&#x66F4;&#x8A73;&#x7D30;&#x7684;&#x8ABF;&#x7528;&#x68E7;&#x8CC7;&#x8A0A;&#xFF0C;&#x4F7F;&#x5F97;&#x8ABF;&#x8A66;&#x904E;&#x7A0B;&#x66F4;&#x76F4;&#x89C0;&#x548C;&#x7528;&#x6236;&#x53CB;&#x597D;&#x3002;&#x63D0;</p>
<pre><code class="language-python">import sys

def my_debugger():
    import ipdb
    print(&quot;Custom debugging session starts.&quot;)
    ipdb.set_trace()

sys.breakpointhook = my_debugger

# Somewhere in your code
breakpoint()  # This will trigger `my_debugger` instead of the default pdb.
</code></pre>
<h3 id="%E9%80%B2%E8%A1%8C%E6%80%A7%E8%83%BD%E5%88%86%E6%9E%90"><strong>&#x9032;&#x884C;&#x6027;&#x80FD;&#x5206;&#x6790;</strong></h3>
<p>&#x5728;&#x6027;&#x80FD;&#x95DC;&#x9375;&#x90E8;&#x5206;&#x7684;&#x4EE3;&#x78BC;&#x4E2D;&#x4F7F;&#x7528;<code>breakpoint()</code>&#xFF0C;&#x6AA2;&#x67E5;&#x7279;&#x5B9A;&#x64CD;&#x4F5C;&#x524D;&#x5F8C;&#x7684;&#x7CFB;&#x7D71;&#x72C0;&#x614B;&#x6216;&#x8B8A;&#x6578;&#xFF0C;&#x4F7F;&#x7528;&#x5982; <code>memory_profiler</code> &#x6216; <code>time</code> &#x6A21;&#x584A;&#x4F86;&#x6AA2;&#x6E2C;&#x8A18;&#x61B6;&#x9AD4;&#x4F7F;&#x7528;&#x6216;&#x6642;&#x9593;&#x6D88;&#x8017;&#xFF0C;&#x6709;&#x52A9;&#x65BC;&#x8B58;&#x5225;&#x6548;&#x80FD;&#x74F6;&#x9838;&#x3002;</p>
<pre><code class="language-python">from memory_profiler import memory_usage
import time
import pdb

def perform_heavy_operations():
    # &#x5047;&#x8A2D;&#x9019;&#x662F;&#x4E00;&#x500B;&#x8A18;&#x61B6;&#x9AD4;&#x548C;&#x8655;&#x7406;&#x6642;&#x9593;&#x5BC6;&#x96C6;&#x578B;&#x64CD;&#x4F5C;
    sum = 0
    for i in range(10000000):
        sum += i
    return sum

# &#x6AA2;&#x6E2C;&#x8A18;&#x61B6;&#x9AD4;&#x548C;&#x6642;&#x9593;&#x4F7F;&#x7528;
initial_memory = memory_usage()
start_time = time.time()

# &#x57F7;&#x884C;&#x5BC6;&#x96C6;&#x578B;&#x64CD;&#x4F5C;
result = perform_heavy_operations()

# &#x65B7;&#x9EDE;&#x8A2D;&#x7F6E;
breakpoint()  # &#x5728;&#x6B64;&#x8655;&#x89F8;&#x767C;&#x65B7;&#x9EDE;&#x4EE5;&#x6AA2;&#x8996;&#x7576;&#x524D;&#x72C0;&#x614B;

final_memory = memory_usage()
end_time = time.time()

# &#x8A08;&#x7B97;&#x4F7F;&#x7528;&#x7684;&#x8A18;&#x61B6;&#x9AD4;&#x548C;&#x6642;&#x9593;
memory_used = final_memory[0] - initial_memory[0]  # &#x55AE;&#x4F4D;&#x70BA; MiB
time_taken = end_time - start_time  # &#x55AE;&#x4F4D;&#x70BA;&#x79D2;

print(f&quot;Result of operations: {result}&quot;)
print(f&quot;Memory used: {memory_used} MiB&quot;)
print(f&quot;Time taken: {time_taken} seconds&quot;)
</code></pre>
<h2 id="%E7%B8%BD%E7%B5%90">&#x7E3D;&#x7D50;</h2>
<h3 id="breakpoint-%E7%9A%84%E5%9F%BA%E6%9C%AC%E5%8A%9F%E8%83%BD%EF%BC%9A"><code>breakpoint()</code> &#x7684;&#x57FA;&#x672C;&#x529F;&#x80FD;&#xFF1A;</h3>
<ul><li><strong>&#x66AB;&#x505C;&#x7A0B;&#x5E8F;&#x57F7;&#x884C;</strong>&#xFF1A;&#x5728;&#x6307;&#x5B9A;&#x7684;&#x4EE3;&#x78BC;&#x9EDE;&#x66AB;&#x505C;&#x57F7;&#x884C;&#xFF0C;&#x9032;&#x5165;&#x5075;&#x932F;&#x6A21;&#x5F0F;&#x3002;</li><li><strong>&#x4E92;&#x52D5;&#x5F0F;&#x8ABF;&#x8A66;&#x74B0;&#x5883;</strong>&#xFF1A;&#x5141;&#x8A31;&#x67E5;&#x770B;&#x8B8A;&#x6578;&#x3001;&#x9010;&#x6B65;&#x57F7;&#x884C;&#x7A0B;&#x5F0F;&#x78BC;&#x3001;&#x6AA2;&#x67E5;&#x8ABF;&#x7528;&#x68E7;&#x7B49;&#x3002;</li><li><strong>&#x7C21;&#x5316;&#x8ABF;&#x8A66;&#x904E;&#x7A0B;</strong>&#xFF1A;&#x63D0;&#x4F9B;&#x4E00;&#x500B;&#x76F4;&#x89C0;&#x7684;&#x65B9;&#x5F0F;&#x4F86;&#x9010;&#x6B65;&#x901A;&#x904E;&#x7A0B;&#x5F0F;&#x78BC;&#xFF0C;&#x627E;&#x51FA;&#x932F;&#x8AA4;&#x7684;&#x4F86;&#x6E90;&#x3002;</li></ul>
<h3 id="breakpoint-%E4%BD%BF%E7%94%A8%E6%8A%80%E5%B7%A7%EF%BC%9A"><code>breakpoint()</code> &#x4F7F;&#x7528;&#x6280;&#x5DE7;&#xFF1A;</h3>
<ul><li><strong>&#x689D;&#x4EF6;&#x65B7;&#x9EDE;</strong>&#xFF1A;&#x5728;&#x7B26;&#x5408;&#x7279;&#x5B9A;&#x689D;&#x4EF6;&#x6642;&#x624D;&#x89F8;&#x767C;&#x65B7;&#x9EDE;&#xFF0C;&#x9069;&#x7528;&#x65BC;&#x5FAA;&#x74B0;&#x6216;&#x689D;&#x4EF6;&#x8A9E;&#x53E5;&#x4E2D;&#x3002;</li><li><strong>&#x52D5;&#x614B;&#x65B7;&#x9EDE;</strong>&#xFF1A;&#x6839;&#x64DA;&#x904B;&#x884C;&#x6642;&#x6578;&#x64DA;&#x6216;&#x689D;&#x4EF6;&#x52D5;&#x614B;&#x8A2D;&#x7F6E;&#x65B7;&#x9EDE;&#xFF0C;&#x4EE5;&#x9748;&#x6D3B;&#x8ABF;&#x6574;&#x8ABF;&#x8A66;&#x7B56;&#x7565;&#x3002;</li><li><strong>&#x6574;&#x5408;&#x65E5;&#x8A8C;</strong>&#xFF1A;&#x5728;&#x9032;&#x5165;&#x548C;&#x96E2;&#x958B;&#x8ABF;&#x8A66;&#x5668;&#x6642;&#x8A18;&#x9304;&#x65E5;&#x8A8C;&#xFF0C;&#x65B9;&#x4FBF;&#x8FFD;&#x8E64;&#x7A0B;&#x5F0F;&#x904B;&#x884C;&#x72C0;&#x614B;&#x3002;</li><li><strong>&#x81EA;&#x5B9A;&#x7FA9; <code>sys.breakpointhook</code></strong>&#xFF1A;&#x81EA;&#x5B9A;&#x7FA9;&#x65B7;&#x9EDE;&#x884C;&#x70BA;&#xFF0C;&#x53EF;&#x6574;&#x5408;&#x5176;&#x4ED6;&#x5DE5;&#x5177;&#x6216;&#x57F7;&#x884C;&#x7279;&#x5B9A;&#x8ABF;&#x8A66;&#x4EE3;&#x78BC;&#x3002;</li></ul>
<h3 id="%E4%BD%BF%E7%94%A8-breakpoint-%E9%80%B2%E8%A1%8C%E6%80%A7%E8%83%BD%E5%88%86%E6%9E%90%EF%BC%9A">&#x4F7F;&#x7528; <code>breakpoint()</code> &#x9032;&#x884C;&#x6027;&#x80FD;&#x5206;&#x6790;&#xFF1A;</h3>
<ul><li><strong>&#x6AA2;&#x6E2C;&#x8A18;&#x61B6;&#x9AD4;&#x548C;&#x6642;&#x9593;&#x4F7F;&#x7528;</strong>&#xFF1A;&#x4F7F;&#x7528; <code>memory_profiler</code> &#x548C; <code>time</code> &#x6A21;&#x584A;&#x5728;&#x65B7;&#x9EDE;&#x524D;&#x5F8C;&#x6E2C;&#x91CF;&#x8A18;&#x61B6;&#x9AD4;&#x548C;&#x57F7;&#x884C;&#x6642;&#x9593;&#xFF0C;&#x4EE5;&#x8B58;&#x5225;&#x6548;&#x80FD;&#x74F6;&#x9838;&#x3002;</li><li><strong>&#x5206;&#x6790;&#x64CD;&#x4F5C;&#x6548;&#x679C;</strong>&#xFF1A;&#x900F;&#x904E;&#x65B7;&#x9EDE;&#x6AA2;&#x8996;&#x7279;&#x5B9A;&#x64CD;&#x4F5C;&#x5C0D;&#x7CFB;&#x7D71;&#x8CC7;&#x6E90;&#x7684;&#x5F71;&#x97FF;&#xFF0C;&#x4E26;&#x8A55;&#x4F30;&#x512A;&#x5316;&#x7B56;&#x7565;&#x3002;</li></ul>
<p>&#x9019;&#x4E9B;&#x7E3D;&#x7D50;&#x9EDE;&#x5E6B;&#x52A9;&#x4F60;&#x66F4;&#x6709;&#x6548;&#x5730;&#x5229;&#x7528; <code>breakpoint()</code> &#x4F86;&#x9032;&#x884C;&#x932F;&#x8AA4;&#x6392;&#x67E5;&#x548C;&#x6027;&#x80FD;&#x5206;&#x6790;&#xFF0C;&#x63D0;&#x5347;&#x958B;&#x767C;&#x6548;&#x7387;&#x548C;&#x7A0B;&#x5F0F;&#x7684;&#x904B;&#x884C;&#x6548;&#x80FD;&#x3002;</p>]]></content:encoded></item><item><title><![CDATA[VS Code Note 01]]></title><description><![CDATA[<h1 id="vs-code%E5%A5%97%E4%BB%B6%E5%AE%89%E8%A3%9D%E8%A8%98%E9%8C%84">VS Code&#x5957;&#x4EF6;&#x5B89;&#x88DD;&#x8A18;&#x9304;</h1><p>VS Code&#x5C0D;&#x65BC;&#x958B;&#x767C;&#x8005;&#x4F86;&#x8AAA;&#x662F;&#x4E00;&#x4EF6;&#x975E;&#x5E38;&#x597D;&#x7528;&#x7684;IDE&#xFF0C;&#x53EF;&#x4EE5;&#x6839;&#x64DA;&#x4E0D;&#x540C;&#x7684;&#x958B;&#x767C;&#x74B0;&#x5883;&#x5B89;&#x88DD;&#x5404;&#x7A2E;&#x64F4;&#x5145;&#x5957;&#x4EF6;&#xFF0C;&#x81EA;&#x5DF1;&#x672C;</p>]]></description><link>https://ghost.augustushsu.com/vscode-note01/</link><guid isPermaLink="false">64e1fd49aacca70ecacc0ead</guid><category><![CDATA[VSCode-Note]]></category><dc:creator><![CDATA[AugustusHsu]]></dc:creator><pubDate>Wed, 27 Mar 2024 12:00:00 GMT</pubDate><media:content url="https://ghost.augustushsu.com/content/images/2024/09/vscode-note01.png" medium="image"/><content:encoded><![CDATA[<h1 id="vs-code%E5%A5%97%E4%BB%B6%E5%AE%89%E8%A3%9D%E8%A8%98%E9%8C%84">VS Code&#x5957;&#x4EF6;&#x5B89;&#x88DD;&#x8A18;&#x9304;</h1><img src="https://ghost.augustushsu.com/content/images/2024/09/vscode-note01.png" alt="VS Code Note 01"><p>VS Code&#x5C0D;&#x65BC;&#x958B;&#x767C;&#x8005;&#x4F86;&#x8AAA;&#x662F;&#x4E00;&#x4EF6;&#x975E;&#x5E38;&#x597D;&#x7528;&#x7684;IDE&#xFF0C;&#x53EF;&#x4EE5;&#x6839;&#x64DA;&#x4E0D;&#x540C;&#x7684;&#x958B;&#x767C;&#x74B0;&#x5883;&#x5B89;&#x88DD;&#x5404;&#x7A2E;&#x64F4;&#x5145;&#x5957;&#x4EF6;&#xFF0C;&#x81EA;&#x5DF1;&#x672C;&#x8EAB;&#x662F;&#x5BEB;&#x6DF1;&#x5EA6;&#x5B78;&#x7FD2;&#x7684;&#x5C08;&#x6848;&#xFF0C;&#x4E0D;&#x904E;&#x9019;&#x88E1;&#x4ECB;&#x7D39;&#x7684;&#x5957;&#x4EF6;&#x61C9;&#x8A72;&#x4E5F;&#x53EF;&#x4EE5;&#x5957;&#x7528;&#x5230;&#x591A;&#x6578;&#x958B;&#x767C;&#x74B0;&#x5883;&#xFF0C;&#x5177;&#x9AD4;&#x7684;&#x53EF;&#x80FD;&#x9700;&#x8981;&#x81EA;&#x884C;&#x6E2C;&#x8A66;&#x624D;&#x6703;&#x77E5;&#x9053;&#x5408;&#x4E0D;&#x5408;&#x9069;&#xFF0C;&#x76EE;&#x524D;&#x5B89;&#x88DD;&#x7684;&#x5957;&#x4EF6;&#x6709;&#x4EE5;&#x4E0B;&#x9019;&#x5E7E;&#x7A2E;:</p><!--kg-card-begin: markdown--><ul>
<li>Git&#x76F8;&#x95DC;&#x7684;VS Code&#x5957;&#x4EF6;
<ul>
<li><a href="#gitlab-workflow">GitLab Workflow</a></li>
<li><a href="#gitlens">GitLens</a></li>
<li><a href="#git-graph">Git Graph</a></li>
</ul>
</li>
<li>&#x8F14;&#x52A9;&#x958B;&#x767C;&#x7684;VS Code&#x5957;&#x4EF6;
<ul>
<li><a href="#settings-sync">Settings Sync</a></li>
<li><a href="#project-manager">Project Manager</a></li>
<li><a href="#metarial-icon-theme">Metarial Icon Theme</a></li>
<li><a href="#todo-tree">TODO Tree</a></li>
<li><a href="#autodocstring">autoDocstring</a></li>
<li><a href="#rainbow-fart">Rainbow Fart</a></li>
</ul>
</li>
<li>Python&#x76F8;&#x95DC;&#x7684;VS Code&#x5957;&#x4EF6;
<ul>
<li>Python</li>
<li>Pylance</li>
<li><a href="#python-indent">Python Indent</a></li>
<li><a href="#python-environment-manager">Python Environment Manager</a></li>
</ul>
</li>
</ul>
<!--kg-card-end: markdown--><h2 id="git%E7%9B%B8%E9%97%9C%E7%9A%84vs-code%E5%A5%97%E4%BB%B6">Git&#x76F8;&#x95DC;&#x7684;VS Code&#x5957;&#x4EF6;</h2><p>&#x8EDF;&#x9AD4;&#x958B;&#x767C;&#x7684;&#x6D41;&#x7A0B;&#x7E3D;&#x662F;&#x96E2;&#x4E0D;&#x958B;&#x7248;&#x672C;&#x63A7;&#x5236;&#xFF0C;VS Code&#x7684;&#x5957;&#x4EF6;&#x5DF2;&#x7D93;&#x5C07;&#x7248;&#x672C;&#x63A7;&#x5236;&#x7684;&#x4E00;&#x4E9B;&#x529F;&#x80FD;&#x975E;&#x5E38;&#x597D;&#x7684;&#x6574;&#x5408;&#x5230;IDE&#x4E0A;&#x9762;&#xFF0C;&#x4E00;&#x4E9B;&#x5E38;&#x7528;&#x529F;&#x80FD;&#x4E5F;&#x6709;&#x8996;&#x89BA;&#x5316;&#x7684;&#x5957;&#x4EF6;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x3002;</p><h3 id="gitlab-workflow">GitLab Workflow</h3><p>VS Code&#x525B;&#x5B89;&#x88DD;&#x5B8C;&#x672C;&#x8EAB;&#x5C31;&#x53EF;&#x4EE5;Clone Github&#x4E0A;&#x9762;&#x7684;Repository&#xFF0C;&#x5982;&#x679C;&#x662F;&#x8981;&#x7528;Clone GitLab&#x4E0A;&#x7684;project&#x5C31;&#x9700;&#x8981;&#x9019;&#x500B;&#x5957;&#x4EF6;&#x4F86;&#x5E6B;&#x5FD9;&#x9023;&#x7DDA;&#x5230;GitLab&#x4E0A;&#xFF0C;&#x4F7F;&#x7528;&#x65B9;&#x6CD5;&#x4E5F;&#x5F88;&#x7C21;&#x55AE;&#xFF0C;&#x5B89;&#x88DD;VSCode&#x4E0A;&#x7684;GitLab Workflow&#x5957;&#x4EF6;&#x5F8C;&#xFF0C;&#x5982;&#x679C;&#x662F;&#x81EA;&#x67B6;&#x7684;GitLab&#x4F3A;&#x670D;&#x5668;&#xFF0C;&#x9700;&#x8981;&#x5275;&#x5EFA;<code>access token</code>&#x63A5;&#x8457;&#x9EDE;&#x9078;Add Account&#x5C07;token&#x8F38;&#x5165;:</p><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/08/image_o-18.png" class="kg-image" alt="VS Code Note 01" loading="lazy" width="494" height="614"></figure><p>&#x65B0;&#x589E;&#x5B8C;token&#x5F8C;&#x9EDE;&#x9078;&#x8907;&#x88FD;&#x5B58;&#x653E;&#x5EAB;&#xFF0C;&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x591A;&#x4E86;&#x4E00;&#x500B;GitLab&#x9078;&#x9805;&#xFF0C;&#x9EDE;&#x9078;&#x5F8C;&#x5C31;&#x80FD;Clone&#x8A72;&#x5E33;&#x865F;&#x4E0B;&#x7684;&#x5C08;&#x6848;&#x4E86;:</p><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/08/image_o-22.png" class="kg-image" alt="VS Code Note 01" loading="lazy" width="1883" height="533" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/08/image_o-22.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2023/08/image_o-22.png 1000w, https://ghost.augustushsu.com/content/images/size/w1600/2023/08/image_o-22.png 1600w, https://ghost.augustushsu.com/content/images/2023/08/image_o-22.png 1883w" sizes="(min-width: 720px) 720px"></figure><h3 id="gitlens">GitLens</h3><p>&#x5728;&#x958B;&#x767C;&#x5C08;&#x6848;&#x6642;&#x7E3D;&#x662F;&#x6703;&#x9047;&#x5230;&#x4E00;&#x4E9B;&#x60F3;&#x8981;&#x98C6;&#x7F75;&#x9AD2;&#x8A71;&#x72C0;&#x6CC1;&#xFF0C;&#x8B6C;&#x5982;:</p><blockquote>&#x554A;?&#x7A0B;&#x5F0F;&#x600E;&#x9EBC;&#x639B;&#x5728;&#x9019;&#x500B;&#x5730;&#x65B9;?XXX!&#x9019;&#x884C;XX&#x8AB0;&#x5BEB;&#x7684;!</blockquote><p>&#x9019;&#x6642;&#x5019;&#x5C31;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;git blame&#x4F86;&#x627E;&#x51FA;&#x5C0E;&#x81F4;&#x767C;&#x751F;&#x9019;&#x7A2E;&#x4E8B;&#x7684;&#x5147;&#x624B;&#xFF0C;&#x800C;GitLens&#x5C31;&#x662F;&#x53EF;&#x4EE5;&#x5728;&#x6BCF;&#x4E00;&#x884C;&#x7A0B;&#x5F0F;&#x78BC;&#x5F8C;&#x9762;&#x52A0;&#x4E0A;git blame&#x7684;&#x8A0A;&#x606F;:</p><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/08/image_o-24.png" class="kg-image" alt="VS Code Note 01" loading="lazy" width="654" height="81" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/08/image_o-24.png 600w, https://ghost.augustushsu.com/content/images/2023/08/image_o-24.png 654w"></figure><p>&#x9664;&#x6B64;&#x4E4B;&#x5916;&#x9084;&#x53EF;&#x4EE5;&#x91DD;&#x5C0D;&#x9019;&#x500B;&#x6A94;&#x6848;&#x6216;&#x662F;&#x884C;&#x53BB;&#x67E5;&#x904E;&#x5F80;&#x7684;commit&#x7D00;&#x9304;:</p><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/08/image-28.png" class="kg-image" alt="VS Code Note 01" loading="lazy" width="420" height="1206"></figure><p>&#x5728;&#x53F3;&#x4E0A;&#x89D2;&#x7684;&#x6309;&#x9215;&#x9084;&#x53EF;&#x4EE5;&#x6BD4;&#x5C0D;&#x524D;&#x4E00;&#x6B21;commit&#x7684;&#x5DEE;&#x7570;:</p><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/08/image-25.png" class="kg-image" alt="VS Code Note 01" loading="lazy" width="273" height="106"></figure><p>&#x9EDE;&#x9078;&#x5F8C;&#x5C31;&#x50CF;&#x4E0B;&#x9762;&#x9019;&#x5F35;&#x5716;&#x7247;&#xFF0C;&#x57FA;&#x672C;&#x4E0A;&#x5C31;&#x662F;git diff&#x756B;&#x9762;&#xFF0C;&#x6BD4;&#x8D77;&#x547D;&#x4EE4;&#x5217;&#x53CB;&#x5584;&#x8A31;&#x591A;:</p><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/08/image-30.png" class="kg-image" alt="VS Code Note 01" loading="lazy" width="1380" height="621" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/08/image-30.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2023/08/image-30.png 1000w, https://ghost.augustushsu.com/content/images/2023/08/image-30.png 1380w" sizes="(min-width: 720px) 720px"></figure><p>&#x5728;&#x4E0B;&#x9762;&#x9084;&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x6700;&#x8FD1;&#x4E00;&#x6B21;commit&#x7684;&#x6642;&#x9593;&#x548C;commit&#x7684;&#x5167;&#x5BB9;&#xFF0C;&#x53EF;&#x4EE5;&#x5FEB;&#x901F;&#x638C;&#x63E1;&#x4E0A;&#x6B21;commit&#x505A;&#x4E86;&#x4EC0;&#x9EBC;:</p><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/08/image-29.png" class="kg-image" alt="VS Code Note 01" loading="lazy" width="1322" height="411" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/08/image-29.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2023/08/image-29.png 1000w, https://ghost.augustushsu.com/content/images/2023/08/image-29.png 1322w" sizes="(min-width: 720px) 720px"></figure><h3 id="git-graph">Git Graph</h3><p>Git Graph&#x7B97;&#x662F;&#x6211;&#x5728;git&#x76F8;&#x95DC;&#x5957;&#x4EF6;&#x4E2D;&#x6700;&#x559C;&#x6B61;&#x7684;&#x5957;&#x4EF6;&#x4E4B;&#x4E00;&#x4E86;&#xFF0C;&#x7576;&#x591A;&#x4EBA;&#x5354;&#x4F5C;&#x6642;&#xFF0C;&#x6BCF;&#x500B;&#x4EBA;&#x90FD;&#x6703;&#x958B;&#x4E00;&#x500B;branch&#xFF0C;&#x900F;&#x904E;Git Graph&#x53EF;&#x4EE5;&#x67E5;&#x770B;&#x5404;&#x500B;branch&#x3001;&#x548C;&#x5404;&#x500B;commit&#x3001;merge&#x7684;&#x72C0;&#x6CC1;&#xFF0C;&#x9664;&#x6B64;&#x4E4B;&#x5916;&#x9084;&#x53EF;&#x4EE5;&#x505A;&#x4E00;&#x4E9B;&#x57FA;&#x672C;&#x64CD;&#x4F5C;&#xFF0C;&#x6BD4;&#x5982;&#x5206;&#x652F;&#x5408;&#x4F75;&#x3001;<code>rebase</code>&#x3001;<code>tag</code>&#x3001;<code>stash</code> &#x7B49;&#x7B49;:</p><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/08/image-31.png" class="kg-image" alt="VS Code Note 01" loading="lazy" width="1042" height="804" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/08/image-31.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2023/08/image-31.png 1000w, https://ghost.augustushsu.com/content/images/2023/08/image-31.png 1042w" sizes="(min-width: 720px) 720px"></figure><h3 id="git-commit-lint-vscode">git-commit-lint-vscode</h3><p>&#x7528;&#x4F86;&#x898F;&#x5B9A;git commit&#x6A19;&#x984C;&#x5728;&#x6307;&#x5B9A;&#x7684;&#x985E;&#x578B;&#x6E05;&#x55AE;&#x4E2D;&#x9078;&#x64C7;&#xFF0C;&#x53EF;&#x4EE5;&#x5C0D;&#x8A72;&#x985E;&#x578B;&#x7684;&#x8AAA;&#x660E;&#x6DFB;&#x52A0;&#x81EA;&#x8A02;&#x7684;&#x6558;&#x8FF0;&#xFF0C;&#x9084;&#x53EF;&#x4EE5;&#x5C0D;&#x4E0D;&#x540C;&#x7684;&#x985E;&#x578B;&#x8A2D;&#x5B9A;&#x6307;&#x5B9A;&#x7684;Emoji:</p><pre><code class="language-json">&quot;gitCommitLintVscode.customType&quot;: [
    {
        &quot;emoji&quot;: &quot;&#x1F389;&quot;,
        &quot;type&quot;: &quot;init&quot;,
        &quot;name&quot;: &quot;&#x521D;&#x59CB;&#x5316;&quot;,
        &quot;description&quot;: &quot;&#x521D;&#x6B21;&#x63D0;&#x4EA4;/&#x521D;&#x59CB;&#x5316;&#x5C08;&#x6848;&quot;
    },
    {
        &quot;emoji&quot;: &quot;&#x2728;&quot;,
        &quot;type&quot;: &quot;feat&quot;,
        &quot;name&quot;: &quot;&#x529F;&#x80FD;&quot;,
        &quot;description&quot;: &quot;&#x65B0;&#x589E;/&#x4FEE;&#x6539;&#x529F;&#x80FD; (feature)&quot;
    },
    {
        &quot;emoji&quot;: &quot;&#x1F41B;&quot;,
        &quot;type&quot;: &quot;fix&quot;,
        &quot;name&quot;: &quot;&#x4FEE;&#x5FA9;bug&quot;,
        &quot;description&quot;: &quot;&#x4FEE;&#x5FA9;bug (bug fix)&quot;
    },
    {
        &quot;emoji&quot;: &quot;&#x1F4DD;&quot;,
        &quot;type&quot;: &quot;docs&quot;,
        &quot;name&quot;: &quot;&#x6587;&#x6A94;&quot;,
        &quot;description&quot;: &quot;&#x6DFB;&#x52A0;/&#x66F4;&#x65B0;&#x6587;&#x6A94;&#xFF0C;&#x5B8C;&#x5584;&#x5C08;&#x6848;&#x8AAA;&#x660E; (documentation)&quot;
    },
    {
        &quot;emoji&quot;: &quot;&#x1F484;&quot;,
        &quot;type&quot;: &quot;style&quot;,
        &quot;name&quot;: &quot;&#x4EE3;&#x78BC;&#x98A8;&#x683C;&#x3001;&#x683C;&#x5F0F;&quot;,
        &quot;description&quot;: &quot;&#x7A0B;&#x5F0F;&#x78BC;&#x98A8;&#x683C;&#x8B8A;&#x66F4;&#xFF0C;&#x4F8B;&#x5982;&#x683C;&#x5F0F;&#x8ABF;&#x6574;&#xFF0C;&#x4E0D;&#x5F71;&#x97FF;&#x7A0B;&#x5F0F;&#x78BC;&#x904B;&#x884C;&quot;
    },
    {
        &quot;emoji&quot;: &quot;&#x267B;&#xFE0F;&quot;,
        &quot;type&quot;: &quot;refactor&quot;,
        &quot;name&quot;: &quot;&#x7A0B;&#x5F0F;&#x78BC;&#x91CD;&#x69CB;&quot;,
        &quot;description&quot;: &quot;&#x4E0D;&#x5F71;&#x97FF;&#x65E2;&#x6709;&#x7684;&#x529F;&#x80FD;&#x524D;&#x63D0;&#x4E0B;&#xFF0C;&#x6539;&#x9032;&#x7A0B;&#x5F0F;&#x78BC;&#x7684;&#x7D50;&#x69CB;&#x3001;&#x53EF;&#x8B80;&#x6027;&#x548C;&#x7DAD;&#x8B77;&#x6027;&quot;
    },
    {
        &quot;emoji&quot;: &quot;&#x1F44C;&quot;,
        &quot;type&quot;: &quot;perf&quot;,
        &quot;name&quot;: &quot;&#x512A;&#x5316;&quot;,
        &quot;description&quot;: &quot;&#x589E;&#x9032;&#x6548;&#x80FD;&#x3001;&#x4FEE;&#x5FA9;&#x6548;&#x80FD;&#x554F;&#x984C;&#x3001;&#x65B0;&#x589E;&#x6548;&#x80FD;&#x512A;&#x5316; (&#x589E;&#x52A0;&#x5FEB;&#x53D6;)&quot;
    },
    {
        &quot;emoji&quot;: &quot;&#x2705;&quot;,
        &quot;type&quot;: &quot;test&quot;,
        &quot;name&quot;: &quot;&#x6E2C;&#x8A66;&quot;,
        &quot;description&quot;: &quot;&#x6D89;&#x53CA;&#x6E2C;&#x8A66;&#x65B9;&#x9762;&#x7684;&#x66F4;&#x6539;&#xFF0C;&#x5982;&#x65B0;&#x589E;/&#x4FEE;&#x6539;&#x6E2C;&#x8A66;&#x6848;&#x4F8B;&quot;
    },
    {
        &quot;emoji&quot;: &quot;&#x1F6E0;&#xFE0F;&quot;,
        &quot;type&quot;: &quot;chore&quot;,
        &quot;name&quot;: &quot;&#x7DAD;&#x8B77;&#x6027;&#x7684;&#x5DE5;&#x4F5C;&quot;,
        &quot;description&quot;: &quot;&#x5EFA;&#x7F6E;&#x6D41;&#x7A0B;&#x6216;&#x8F14;&#x52A9;&#x5DE5;&#x5177;/&#x5957;&#x4EF6;&#x7684;&#x8B8A;&#x52D5; (&#x4FDD;&#x6301;&#x7A0B;&#x5F0F;&#x78BC;&#x7684;&#x5065;&#x5EB7;&#x548C;&#x53EF;&#x8B80;&#x6027;&#xFF0C;&#x4E0D;&#x76F4;&#x63A5;&#x5F71;&#x97FF;&#x4EE3;&#x78BC;&#x7684;&#x529F;&#x80FD;)&quot;
    },
    {
        &quot;emoji&quot;: &quot;&#x21A9;&#xFE0F;&quot;,
        &quot;type&quot;: &quot;revert&quot;,
        &quot;name&quot;: &quot;&#x64A4;&#x92B7;&quot;,
        &quot;description&quot;: &quot;&#x64A4;&#x92B7;&#x56DE;&#x5FA9;&#x5148;&#x524D;&#x7684;commit (&#x6A19;&#x8A18;&#x64A4;&#x92B7;&#x64CD;&#x4F5C;&#xFF0C;&#x8B93;&#x5718;&#x968A;&#x6210;&#x54E1;&#x66F4;&#x5BB9;&#x6613;&#x4E86;&#x89E3;&#x8B8A;&#x66F4;&#x7684;&#x80CC;&#x666F;&#x548C;&#x539F;&#x56E0;)&quot;
    },
    {
        &quot;emoji&quot;: &quot;&#x2796;&quot;,
        &quot;type&quot;: &quot;&quot;,
        &quot;name&quot;: &quot;&quot;,
        &quot;description&quot;: &quot;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x4EE5;&#x4E0A;&#x70BA;&#x5E38;&#x7528;&#x7684;type&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&#x2500;&quot;
    },
    {
        &quot;emoji&quot;: &quot;&#x1F95A;&quot;,
        &quot;type&quot;: &quot;format&quot;,
        &quot;name&quot;: &quot;&#x683C;&#x5F0F;&#x5316;&#x4EE3;&#x7801;&quot;,
        &quot;description&quot;: &quot;&#x683C;&#x5F0F;&#x5316;&quot;
    },
    {
        &quot;emoji&quot;: &quot;&#x1F691;&quot;,
        &quot;type&quot;: &quot;patch&quot;,
        &quot;name&quot;: &quot;&#x6DFB;&#x52A0;&#x91CD;&#x8981;&#x8865;&#x4E01;&quot;,
        &quot;description&quot;: &quot;&#x8865;&#x4E01;&quot;
    },
    {
        &quot;emoji&quot;: &quot;&#x1F4E6;&quot;,
        &quot;type&quot;: &quot;file&quot;,
        &quot;name&quot;: &quot;&#x6DFB;&#x52A0;&#x65B0;&#x6587;&#x4EF6;&quot;,
        &quot;description&quot;: &quot;&#x65B0;&#x6587;&#x4EF6;&quot;
    },
    {
        &quot;emoji&quot;: &quot;&#x1F680;&quot;,
        &quot;type&quot;: &quot;publish&quot;,
        &quot;name&quot;: &quot;&#x53D1;&#x5E03;&#x65B0;&#x7248;&#x672C;&quot;,
        &quot;description&quot;: &quot;&#x65B0;&#x7248;&#x672C;&quot;
    },
    {
        &quot;emoji&quot;: &quot;&#x1F4CC;&quot;,
        &quot;type&quot;: &quot;tag&quot;,
        &quot;name&quot;: &quot;&#x53D1;&#x5E03;&#x7248;&#x672C;/&#x6DFB;&#x52A0;&#x6807;&#x7B7E;&quot;,
        &quot;description&quot;: &quot;&#x4E66;&#x7B7E;&quot;
    },
    {
        &quot;emoji&quot;: &quot;&#x1F527;&quot;,
        &quot;type&quot;: &quot;config&quot;,
        &quot;name&quot;: &quot;&#x4FEE;&#x6539;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&quot;,
        &quot;description&quot;: &quot;&#x914D;&#x7F6E;&quot;
    },
    {
        &quot;emoji&quot;: &quot;&#x1F648;&quot;,
        &quot;type&quot;: &quot;git&quot;,
        &quot;name&quot;: &quot;&#x6DFB;&#x52A0;&#x6216;&#x4FEE;&#x6539;.gitignore&#x6587;&#x4EF6;&quot;,
        &quot;description&quot;: &quot;&#x4E0D;&#x53EF;&#x89C1;&quot;
    }
]</code></pre><h2 id="%E8%BC%94%E5%8A%A9%E9%96%8B%E7%99%BC%E7%9A%84vs-code%E5%A5%97%E4%BB%B6">&#x8F14;&#x52A9;&#x958B;&#x767C;&#x7684;VS Code&#x5957;&#x4EF6;</h2><p>VS Code&#x5957;&#x4EF6;&#x9664;&#x4E86;&#x6709;&#x5F37;&#x800C;&#x6709;&#x529B;&#x7684;git&#x76F8;&#x95DC;&#x5957;&#x4EF6;&#x4EE5;&#x5916;&#xFF0C;&#x9084;&#x6709;&#x4E00;&#x4E9B;&#x5957;&#x4EF6;&#x53EF;&#x4EE5;&#x5E6B;&#x52A9;&#x81EA;&#x5DF1;&#x7BA1;&#x7406;&#x958B;&#x767C;&#x7684;&#x5C08;&#x6848;&#x3002;</p><h3 id="settings-sync">Settings Sync</h3><p>&#x6BCF;&#x500B;&#x4EBA;&#x5B89;&#x88DD;&#x7684;&#x5957;&#x4EF6;&#x3001;VSCode&#x7684;&#x8A2D;&#x5B9A;&#x9084;&#x6709;<code>setting.json</code>&#x7684;&#x5167;&#x5BB9;&#x90FD;&#x662F;&#x6839;&#x64DA;&#x500B;&#x4EBA;&#x7684;&#x4F7F;&#x7528;&#x72C0;&#x6CC1;&#x800C;&#x88FD;&#x4F5C;&#x7684;&#xFF0C;&#x7576;&#x63DB;&#x4E86;&#x4E00;&#x53F0;&#x96FB;&#x8166;&#xFF0C;&#x7E3D;&#x4E0D;&#x80FD;&#x4E00;&#x4E00;&#x628A;&#x820A;&#x96FB;&#x8166;&#x4E0A;&#x7684;&#x5957;&#x4EF6;&#x88DD;&#x5230;&#x65B0;&#x96FB;&#x8166;&#x4E0A;&#xFF0C;&#x6240;&#x4EE5;&#x9019;&#x6642;&#x5019;&#x5C31;&#x8981;&#x6709;&#x540C;&#x6B65;&#x7684;&#x5DE5;&#x5177;&#x4F86;&#x5132;&#x5B58;&#x7D00;&#x9304;&#x820A;&#x96FB;&#x8166;&#x5B89;&#x88DD;&#x904E;&#x7684;&#x5957;&#x4EF6;&#x3001;&#x4F7F;&#x7528;&#x7684;&#x8A2D;&#x5B9A;&#xFF0C;&#x9084;&#x539F;&#x5230;&#x65B0;&#x96FB;&#x8166;&#x4E0A;&#x3002;</p><p>&#x5957;&#x4EF6;&#x672C;&#x8EAB;&#x5DF2;&#x4E0D;&#x518D;&#x66F4;&#x65B0;&#xFF0C;&#x73FE;&#x5728;&#x4F7F;&#x7528;&#x5167;&#x5EFA;&#x7684;<code>Settings Sync</code>&#x529F;&#x80FD;&#x5373;&#x53EF;&#xFF0C;&#x4F7F;&#x7528;&#x65B9;&#x6CD5;&#x4E5F;&#x5F88;&#x7C21;&#x55AE;&#xFF0C;&#x9EDE;&#x9078;&#x5DE6;&#x4E0B;&#x89D2;&#x7684;&#x9F52;&#x8F2A;&#x5F8C;&#x9078;&#x64C7;<code>&#x958B;&#x555F;&#x8A2D;&#x5B9A;&#x540C;&#x6B65;</code>&#xFF0C;&#x518D;&#x8DDF;<code>Github</code>&#x505A;&#x9023;&#x7D50;&#x5373;&#x53EF;&#x3002;</p><p>&#x8A73;&#x7D30;&#x7684;&#x64CD;&#x4F5C;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x67E5;&#x770B;VS Code&#x7684;<a href="https://code.visualstudio.com/docs/editor/settings-sync?ref=ghost.augustushsu.com">&#x5B98;&#x65B9;&#x8AAA;&#x660E;&#x6587;&#x6A94;</a>&#x3002;</p><h3 id="project-manager">Project Manager</h3><p>&#x7576;&#x540C;&#x6642;&#x8981;&#x958B;&#x767C;&#x597D;&#x5E7E;&#x500B;&#x5C08;&#x6848;&#x6642;&#xFF0C;&#x4F7F;&#x7528;VS Code&#x6703;&#x9700;&#x8981;&#x958B;&#x597D;&#x5E7E;&#x500B;&#x8996;&#x7A97;&#xFF0C;&#x5207;&#x63DB;&#x8996;&#x7A97;&#x6642;&#x7E3D;&#x662F;&#x6703;&#x5206;&#x4E0D;&#x6E05;&#x54EA;&#x500B;&#x8996;&#x7A97;&#x662F;&#x54EA;&#x500B;&#x5C08;&#x6848;&#x7684;&#xFF0C;&#x53EF;&#x4EE5;&#x900F;&#x904E;&#x9019;&#x500B;&#x5957;&#x4EF6;&#x76F4;&#x63A5;&#x5728;&#x4E00;&#x500B;&#x8996;&#x7A97;&#x4E2D;&#x5207;&#x63DB;&#x4E0D;&#x540C;&#x5C08;&#x6848;&#xFF0C;&#x4F7F;&#x7528;&#x65B9;&#x6CD5;&#x4E5F;&#x5F88;&#x7C21;&#x55AE;&#xFF0C;&#x958B;&#x555F;&#x8981;&#x958B;&#x767C;&#x7684;&#x5C08;&#x6848;&#x7136;&#x5F8C;&#x9EDE;&#x9078;Save Project&#xFF0C;&#x63A5;&#x8457;&#x547D;&#x540D;&#x5C08;&#x6848;&#x540D;&#x7A31;&#x5C31;&#x53EF;&#x4EE5;&#x986F;&#x793A;&#x5728;&#x5DE6;&#x908A;&#x7684;&#x6E05;&#x55AE;&#x4E2D;&#x4E86;:</p><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/08/image-3-1.png" class="kg-image" alt="VS Code Note 01" loading="lazy" width="1393" height="553" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/08/image-3-1.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2023/08/image-3-1.png 1000w, https://ghost.augustushsu.com/content/images/2023/08/image-3-1.png 1393w" sizes="(min-width: 720px) 720px"></figure><p>&#x8981;&#x65B0;&#x589E;&#x5176;&#x4ED6;&#x7684;&#x5C08;&#x6848;&#x4E5F;&#x662F;&#x4E00;&#x6A23;&#xFF0C;&#x958B;&#x555F;&#x5176;&#x4ED6;&#x5C08;&#x6848;&#x5F8C;&#x9EDE;&#x9078;&#x6E05;&#x55AE;&#x65C1;&#x908A;&#x88AB;&#x7D05;&#x6846;&#x5708;&#x9078;&#x8D77;&#x4F86;&#x7684;&#x5716;&#x793A;&#x65B0;&#x589E;&#x5230;&#x5DE6;&#x908A;&#xFF0C;&#x9700;&#x8981;&#x5207;&#x63DB;&#x7684;&#x8A71;&#x9EDE;&#x4E00;&#x4E0B;&#x5C31;&#x53EF;&#x4EE5;&#x5207;&#x63DB;&#x4E0D;&#x540C;&#x7684;&#x5C08;&#x6848;:</p><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/08/image-4-1.png" class="kg-image" alt="VS Code Note 01" loading="lazy" width="1415" height="556" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/08/image-4-1.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2023/08/image-4-1.png 1000w, https://ghost.augustushsu.com/content/images/2023/08/image-4-1.png 1415w" sizes="(min-width: 720px) 720px"></figure><h3 id="metarial-icon-theme">Metarial Icon Theme</h3><p>&#x9019;&#x500B;&#x5957;&#x4EF6;&#x529F;&#x80FD;&#x5F88;&#x7C21;&#x55AE;&#xFF0C;&#x57FA;&#x672C;&#x4E0A;&#x5C31;&#x662F;&#x66FF;&#x63DB;&#x5728;VS Code&#x4E2D;&#x51FA;&#x73FE;&#x7684;Icon&#xFF0C;&#x5177;&#x9AD4;&#x66FF;&#x63DB;&#x7684;&#x5716;&#x793A;&#x53EF;&#x4EE5;&#x53C3;&#x8003;&#x5957;&#x4EF6;&#x4E0A;&#x7684;&#x8AAA;&#x660E;:</p><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/08/image-8-1.png" class="kg-image" alt="VS Code Note 01" loading="lazy" width="864" height="858" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/08/image-8-1.png 600w, https://ghost.augustushsu.com/content/images/2023/08/image-8-1.png 864w" sizes="(min-width: 720px) 720px"></figure><p>&#x5982;&#x679C;&#x4E0D;&#x559C;&#x6B61;&#x9019;&#x500B;&#x5957;&#x4EF6;&#x66F4;&#x63DB;&#x7684;&#x5716;&#x793A;&#xFF0C;&#x53EF;&#x4EE5;&#x8A66;&#x8A66;&#x770B;<code>file-icons</code>&#xFF0C;&#x9019;&#x500B;&#x5957;&#x4EF6;&#x7684;&#x5716;&#x793A;&#x6574;&#x9AD4;&#x4EAE;&#x5EA6;&#x6703;&#x6BD4;&#x4E0A;&#x4E00;&#x500B;&#x7A0D;&#x4F4E;&#xFF0C;&#x4E5F;&#x662F;&#x4E00;&#x500B;&#x4E0D;&#x932F;&#x7684;&#x9078;&#x64C7;:</p><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/08/image-7-1.png" class="kg-image" alt="VS Code Note 01" loading="lazy" width="831" height="730" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/08/image-7-1.png 600w, https://ghost.augustushsu.com/content/images/2023/08/image-7-1.png 831w" sizes="(min-width: 720px) 720px"></figure><h3 id="todo-tree">TODO Tree</h3><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/08/image-16.png" class="kg-image" alt="VS Code Note 01" loading="lazy" width="856" height="205" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/08/image-16.png 600w, https://ghost.augustushsu.com/content/images/2023/08/image-16.png 856w" sizes="(min-width: 720px) 720px"></figure><p>&#x5728;&#x5BEB;&#x7A0B;&#x5F0F;&#x6642;&#x7E3D;&#x6709;&#x4E9B;&#x6642;&#x5019;&#x6703;&#x7A81;&#x7136;&#x6709;&#x65B0;&#x7684;&#x60F3;&#x6CD5;&#xFF0C;&#x611F;&#x89BA;&#x53EF;&#x4EE5;&#x5728;&#x67D0;&#x6BB5;&#x7A0B;&#x5F0F;&#x78BC;&#x4E2D;&#x52A0;&#x4E0A;&#x4E00;&#x4E9B;&#x529F;&#x80FD;&#x3001;&#x6216;&#x662F;&#x512A;&#x5316;&#x9019;&#x6BB5;&#x7A0B;&#x5F0F;&#x78BC;&#xFF0C;&#x901A;&#x5E38;&#x6703;&#x5BEB;&#x4E00;&#x4E9B;&#x8A3B;&#x89E3;&#x5728;&#x60F3;&#x4FEE;&#x6539;&#x7684;&#x7A0B;&#x5F0F;&#x9644;&#x8FD1;&#xFF0C;&#x4F46;&#x662F;&#x7576;&#x6B63;&#x5728;&#x958B;&#x767C;&#x7684;&#x90E8;&#x5206;&#x544A;&#x4E00;&#x6BB5;&#x843D;&#x5F8C;&#xFF0C;&#x7A81;&#x7136;&#x767C;&#x73FE;&#x60F3;&#x4E0D;&#x8D77;&#x4F86;&#x60F3;&#x8981;&#x52A0;&#x4E0A;&#x7684;&#x529F;&#x80FD;&#x6216;&#x662F;&#x512A;&#x5316;&#x7684;&#x65B9;&#x6CD5;&#x5728;&#x54EA;&#xFF1B;&#x4E5F;&#x6709;&#x4E9B;&#x6642;&#x5019;&#x6709;&#x6BB5;&#x7A0B;&#x5F0F;&#x78BC;&#x51FA;&#x73FE;&#x4E86;bug&#xFF0C;&#x70BA;&#x4E86;&#x8981;debug&#x800C;&#x65B0;&#x589E;&#x67D0;&#x6BB5;&#x7A0B;&#x5F0F;&#xFF0C;&#x7576;&#x4FEE;&#x5FA9;&#x597D;bug&#x5F8C;&#x5FD8;&#x8A18;&#x4FEE;&#x6539;&#x7684;&#x5730;&#x65B9;&#x5728;&#x54EA;&#xFF0C;&#x5C0E;&#x81F4;&#x7522;&#x751F;&#x4E86;&#x65B0;&#x7684;bug&#x3002;</p><p>&#x800C;&#x9019;&#x500B;&#x5957;&#x4EF6;&#x5C0D;&#x65BC;&#x958B;&#x767C;&#x4F86;&#x8AAA;&#x5F88;&#x65B9;&#x4FBF;&#xFF0C;&#x53EF;&#x4EE5;&#x7BA1;&#x7406;&#x5728;&#x5C08;&#x6848;&#x4E2D;&#x4E00;&#x4E9B;&#x81E8;&#x6642;&#x65B0;&#x589E;&#x7684;&#x6E2C;&#x8A66;&#x7A0B;&#x5F0F;&#x78BC;&#x6216;&#x662F;&#x60F3;&#x5728;&#x8981;&#x65B0;&#x589E;&#x7684;&#x529F;&#x80FD;&#x8AAA;&#x660E;&#xFF0C;&#x5982;&#x4E0B;&#x53EF;&#x4EE5;&#x5728;&#x67D0;&#x6BB5;&#x7A0B;&#x5F0F;&#x78BC;&#x4E0A;&#x589E;&#x52A0;&#x8A3B;&#x89E3;&#xFF0C;&#x4E26;&#x7D71;&#x4E00;&#x7BA1;&#x7406;:</p><figure class="kg-card kg-image-card kg-width-wide"><img src="https://ghost.augustushsu.com/content/images/2023/08/image-13-1.png" class="kg-image" alt="VS Code Note 01" loading="lazy" width="1405" height="545" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/08/image-13-1.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2023/08/image-13-1.png 1000w, https://ghost.augustushsu.com/content/images/2023/08/image-13-1.png 1405w" sizes="(min-width: 1200px) 1200px"></figure><p>Todo Tree&#x8A2D;&#x5B9A;&#x6392;&#x9664;&#x7684;&#x8CC7;&#x6599;&#x593E;&#x53EF;&#x4EE5;&#x5728;&#x8A2D;&#x5B9A;&#x88E1;&#x9762;&#x641C;&#x5C0B;<code>Todo-tree &#x203A; Filtering: Exclude Globs</code>&#xFF0C;&#x5C07;&#x8981;&#x6392;&#x9664;&#x7684;&#x8CC7;&#x6599;&#x593E;&#x586B;&#x5165;:</p><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/09/image-46.png" class="kg-image" alt="VS Code Note 01" loading="lazy" width="873" height="171" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/09/image-46.png 600w, https://ghost.augustushsu.com/content/images/2023/09/image-46.png 873w" sizes="(min-width: 720px) 720px"></figure><p>&#x53EF;&#x4EE5;&#x8A2D;&#x5B9A;&#x81EA;&#x5DF1;Todo Tree&#x7684;&#x8A3B;&#x89E3;&#x6A23;&#x5F0F;&#xFF0C;icon&#x7684;&#x90E8;&#x5206;&#x53EF;&#x4EE5;&#x53BB;<a href="https://microsoft.github.io/vscode-codicons/dist/codicon.html?ref=ghost.augustushsu.com">&#x9019;&#x500B;&#x7DB2;&#x7AD9;</a>&#x4E0A;&#x67E5;&#xFF0C;&#x4E0B;&#x9762;&#x662F;&#x6211;&#x7684;&#x8A2D;&#x5B9A;&#x6A94;:</p><pre><code class="language-JSON">&quot;todo-tree.general.tags&quot;: [
    &quot;TODO&quot;,
    &quot;TEST&quot;,
    &quot;BUG&quot;,
    &quot;FIXME&quot;,
    &quot;FIX&quot;,
    &quot;HACK&quot;,
    &quot;NOTE&quot;,
    &quot;TAG&quot;,
    &quot;DONE&quot;
],
&quot;todo-tree.highlights.customHighlight&quot;: {
    &quot;TODO&quot;: {
        &quot;icon&quot;: &quot;checklist&quot;,
        &quot;foreground&quot;: &quot;#000000&quot;,
        &quot;background&quot;: &quot;#ffffff&quot;,
        &quot;iconColour&quot;: &quot;#ffffff&quot;,
        &quot;rulerColour&quot;: &quot;#ffffff&quot;,
        &quot;gutterIcon&quot;: true
    },
    &quot;BUG&quot;: {
        &quot;icon&quot;: &quot;bug&quot;,
        &quot;background&quot;: &quot;#d10000&quot;,
        &quot;foreground&quot;: &quot;#ffffff&quot;,
        &quot;iconColour&quot;: &quot;#d10000&quot;,
        &quot;rulerColour&quot;: &quot;#d10000&quot;,
        &quot;gutterIcon&quot;: true
    },
    &quot;FIXME&quot;: {
        &quot;icon&quot;: &quot;flame&quot;,
        &quot;background&quot;: &quot;#a32cc4&quot;,
        &quot;foreground&quot;: &quot;#ffffff&quot;,
        &quot;iconColour&quot;: &quot;#a32cc4&quot;,
        &quot;rulerColour&quot;: &quot;#a32cc4&quot;,
        &quot;gutterIcon&quot;: true
    },
    &quot;TEST&quot;: {
        &quot;icon&quot;: &quot;beaker&quot;,
        &quot;background&quot;: &quot;#FF4500&quot;,
        &quot;foreground&quot;: &quot;#ffffff&quot;,
        &quot;iconColour&quot;: &quot;#FF4500&quot;,
        &quot;rulerColour&quot;: &quot;#FF4500&quot;,
        &quot;gutterIcon&quot;: true
    },
    &quot;TAG&quot;: {
        &quot;icon&quot;: &quot;tag&quot;,
        &quot;background&quot;: &quot;#0000ff&quot;,
        &quot;foreground&quot;: &quot;#ffffff&quot;,
        &quot;iconColour&quot;: &quot;#0000ff&quot;,
        &quot;rulerColour&quot;: &quot;#0000ff&quot;,
        &quot;gutterIcon&quot;: true
    },
    &quot;NOTE&quot;: {
        &quot;icon&quot;: &quot;bookmark&quot;,
        &quot;background&quot;: &quot;#00ff00&quot;,
        &quot;foreground&quot;: &quot;#ffffff&quot;,
        &quot;iconColour&quot;: &quot;#00ff00&quot;,
        &quot;rulerColour&quot;: &quot;#00ff00&quot;,
        &quot;gutterIcon&quot;: true
    },
    &quot;DONE&quot;: {
        &quot;icon&quot;: &quot;verified&quot;,
        &quot;background&quot;: &quot;#000000&quot;,
        &quot;foreground&quot;: &quot;#ffffff&quot;,
        &quot;iconColour&quot;: &quot;#000000&quot;,
        &quot;rulerColour&quot;: &quot;#000000&quot;,
        &quot;gutterIcon&quot;: true
    },
    &quot;HACK&quot;: {
        &quot;icon&quot;: &quot;rocket&quot;,
        &quot;background&quot;: &quot;#08deea&quot;,
        &quot;foreground&quot;: &quot;#ffffff&quot;,
        &quot;iconColour&quot;: &quot;#08deea&quot;,
        &quot;rulerColour&quot;: &quot;#08deea&quot;,
        &quot;gutterIcon&quot;: true
    }
},
&quot;todo-tree.general.tagGroups&quot;: {
    &quot;FIXME&quot;: [
        &quot;FIXME&quot;,
        &quot;FIX&quot;
    ]
},
&quot;todo-tree.highlights.defaultHighlight&quot;: {
    &quot;type&quot;: &quot;tag&quot;,
    &quot;rulerLane&quot;: &quot;full&quot;
},</code></pre><div class="kg-card kg-toggle-card" data-kg-toggle-state="close"><div class="kg-toggle-heading"><h4 class="kg-toggle-heading-text">&#x81EA;&#x8A02;Highlight&#x8A2D;&#x5B9A;&#x8AAA;&#x660E;</h4><button class="kg-toggle-card-icon"><svg id="Regular" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 24 24"><path class="cls-1" d="M23.25,7.311,12.53,18.03a.749.749,0,0,1-1.06,0L.75,7.311"/></svg></button></div><div class="kg-toggle-content"><p>icon: &#x5716;&#x793A;&#xFF0C;&#x53EF;&#x4EE5;&#x5F9E;&#x4E0A;&#x9762;&#x8AAA;&#x7684;&#x5B98;&#x65B9;&#x7DB2;&#x7AD9;&#x4E2D;&#x67E5;&#x8A62;&#xFF0C;&#x4F46;&#x4E0D;&#x662F;&#x5168;&#x90E8;&#x53EF;&#x4EE5;&#x7528;<br>background: &#x80CC;&#x666F;&#x984F;&#x8272;<br>foreground: &#x524D;&#x666F;&#x6F14;&#x8272; (&#x5B57;&#x9AD4;&#x984F;&#x8272;)<br>iconColour: &#x5716;&#x793A;&#x984F;&#x8272;<br>rulerColour: &#x53F3;&#x908A;&#x6EFE;&#x52D5;&#x689D;&#x4E0A;&#x986F;&#x793A;&#x7684;&#x984F;&#x8272;<br>rulerLane: &#x6EFE;&#x52D5;&#x689D;&#x7684;&#x986F;&#x793A;&#x985E;&#x578B; (left, center, right, full, none)<br>gutterIcon: &#x5728;&#x884C;&#x6578;&#x5DE6;&#x908A;&#x662F;&#x5426;&#x986F;&#x793A;&#x5716;&#x793A;<br>opacity: &#x80CC;&#x666F;&#x7684;&#x4E0D;&#x900F;&#x660E;&#x5EA6;</p></div></div><h3 id="autodocstring">autoDocstring</h3><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/08/image-17.png" class="kg-image" alt="VS Code Note 01" loading="lazy" width="828" height="203" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/08/image-17.png 600w, https://ghost.augustushsu.com/content/images/2023/08/image-17.png 828w" sizes="(min-width: 720px) 720px"></figure><p>&#x5728;&#x7A0B;&#x5F0F;&#x4E2D;&#x8A3B;&#x89E3;&#x6709;&#x591A;&#x91CD;&#x8981;&#x76F8;&#x4FE1;&#x4E0D;&#x9700;&#x8981;&#x904E;&#x591A;&#x7684;&#x5F37;&#x8ABF;&#xFF0C;&#x9019;&#x500B;&#x5957;&#x4EF6;&#x53EF;&#x4EE5;&#x81EA;&#x52D5;&#x7684;&#x628A;&#x6240;&#x6709;&#x51FD;&#x5F0F;&#x7684;&#x8F38;&#x5165;&#x8F38;&#x51FA;&#x53C3;&#x6578;&#x4EE5;&#x6307;&#x5B9A;&#x7684;&#x98A8;&#x683C;&#x751F;&#x6210;&#x8A3B;&#x89E3;&#xFF0C;&#x81EA;&#x5DF1;&#x7FD2;&#x6163;&#x4F7F;&#x7528;&#x7684;google&#x98A8;&#x683C;:</p><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/08/image-14-1.png" class="kg-image" alt="VS Code Note 01" loading="lazy" width="407" height="111"></figure><p>&#x4F7F;&#x7528;&#x65B9;&#x5F0F;&#x4E5F;&#x5F88;&#x7C21;&#x55AE;&#xFF0C;&#x76F4;&#x63A5;&#x5728;&#x51FD;&#x5F0F;&#x4E0B;&#x9762;&#x8F38;&#x5165;<code>&quot;&quot;&quot;</code>&#x5C31;&#x884C;&#xFF0C;&#x4EE5;&#x4E0B;&#x5716;&#x7247;&#x4F86;&#x81EA;&#x8A72;&#x5957;&#x4EF6;&#x7684;&#x8CC7;&#x6599;&#x4E2D;:</p><figure class="kg-card kg-image-card"><img src="https://github.com/NilsJPWerner/autoDocstring/raw/HEAD/images/demo.gif" class="kg-image" alt="VS Code Note 01" loading="lazy"></figure><h3 id="rainbow-fart">Rainbow Fart</h3><p>&#x9019;&#x500B;&#x5957;&#x4EF6;&#x8DA3;&#x5473;&#x6027;&#x5341;&#x8DB3;&#xFF0C;&#x5B83;&#x53EF;&#x4EE5;&#x52A0;&#x901F;&#x958B;&#x767C;&#x7684;&#x901F;&#x5EA6;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x8B93;&#x4F60;&#x5728;&#x5BEB;&#x7A0B;&#x5F0F;&#x7684;&#x6642;&#x5019;&#x5145;&#x6EFF;&#x4FE1;&#x5FC3;&#xFF0C;&#x5728;&#x4F60;&#x8EAB;&#x5FC3;&#x4FF1;&#x75B2;&#x7684;&#x6642;&#x5019;&#x9084;&#x6703;&#x70BA;&#x4F60;&#x63D0;&#x4F9B;&#x5E6B;&#x52A9;&#xFF0C;&#x5177;&#x9AD4;&#x7684;&#x7B49;&#x4F60;&#x5B89;&#x88DD;&#x904E;&#x5F8C;&#x5C31;&#x77E5;&#x9053;(&#x563F;&#x563F;&#x563F;)&#x3002;</p><h2 id="python%E7%9B%B8%E9%97%9C%E7%9A%84vs-code%E5%A5%97%E4%BB%B6">Python&#x76F8;&#x95DC;&#x7684;VS Code&#x5957;&#x4EF6;</h2><p>Python&#x3001;Pylance&#x57FA;&#x672C;&#x4E0A;&#x662F;<strong><strong>&#x5FC5;&#x88DD;</strong></strong>&#x7684;&#x5957;&#x4EF6;&#xFF0C;&#x9019;&#x88E1;&#x4E0D;&#x591A;&#x505A;&#x4ECB;&#x7D39;&#x3002;</p><h3 id="python-indent">Python Indent</h3><p>Python Indent&#x7684;&#x529F;&#x80FD;&#x5F88;&#x7C21;&#x55AE;&#xFF0C;&#x5C31;&#x662F;&#x5C0D;&#x7E2E;&#x6392;&#x9032;&#x884C;&#x512A;&#x5316;&#xFF0C;&#x4EE5;&#x4E0B;&#x662F;&#x5B98;&#x65B9;&#x7684;&#x8AAA;&#x660E;&#x52D5;&#x756B;:</p><figure class="kg-card kg-image-card"><img src="https://github.com/kbrose/vsc-python-indent/raw/HEAD/static/demo.gif" class="kg-image" alt="VS Code Note 01" loading="lazy"></figure><h3 id="python-environment-manager">Python Environment Manager</h3><p>&#x5982;&#x679C;&#x6709;&#x4F7F;&#x7528;coda&#x6216;&#x662F;venv&#x4F86;&#x5EFA;&#x69CB;python&#x74B0;&#x5883;&#x7684;&#x8A71;&#x9019;&#x500B;&#x5957;&#x4EF6;&#x9084;&#x883B;&#x5BE6;&#x7528;&#x7684;&#xFF0C;&#x53EF;&#x4EE5;&#x67E5;&#x770B;&#x76EE;&#x524D;&#x6709;&#x7684;&#x74B0;&#x5883;&#xFF0C;&#x548C;&#x74B0;&#x5883;&#x5167;&#x5B89;&#x88DD;&#x7684;&#x5957;&#x4EF6;&#xFF0C;&#x4E0D;&#x904E;&#x6211;&#x81EA;&#x5DF1;&#x672C;&#x8EAB;&#x9084;&#x662F;&#x7FD2;&#x6163;&#x900F;&#x904E;&#x547D;&#x4EE4;&#x5217;&#x7BA1;&#x7406;&#x74B0;&#x5883;&#xFF0C;&#x7562;&#x7ADF;&#x74B0;&#x5883;&#x9019;&#x6771;&#x897F;&#x4F7F;&#x7528;&#x7684;&#x983B;&#x7387;&#x4E0D;&#x6703;&#x592A;&#x9AD8;&#xFF0C;&#x800C;&#x4E14;&#x76EE;&#x524D;&#x4E5F;&#x883B;&#x591A;&#x5C08;&#x6848;&#x662F;&#x4F7F;&#x7528;docker&#x4F86;&#x5EFA;&#x69CB;&#x74B0;&#x5883;&#x7684;&#xFF0C;&#x6240;&#x4EE5;&#x76EE;&#x524D;&#x662F;&#x6C92;&#x6709;&#x4F7F;&#x7528;&#x9019;&#x500B;&#x5957;&#x4EF6;&#x3002;</p><figure class="kg-card kg-image-card"><img src="https://raw.githubusercontent.com/DonJayamanne/vscode-python-manager/environmentManager/resources/demo.gif" class="kg-image" alt="VS Code Note 01" loading="lazy"></figure>]]></content:encoded></item><item><title><![CDATA[MongoDB Note 01]]></title><description><![CDATA[MongoDB儲存資料的格式彈性，不需要定義Schema，可以輕易的新增、修改資料。]]></description><link>https://ghost.augustushsu.com/mongodb-note01/</link><guid isPermaLink="false">64e1fd49aacca70ecacc0ea5</guid><category><![CDATA[MongoDB]]></category><dc:creator><![CDATA[AugustusHsu]]></dc:creator><pubDate>Sun, 05 Nov 2023 12:00:07 GMT</pubDate><media:content url="https://ghost.augustushsu.com/content/images/2023/10/mongodb-note-01-1.png" medium="image"/><content:encoded><![CDATA[<h1 id="%E5%9F%BA%E7%A4%8E%E6%A6%82%E5%BF%B5%E7%B0%A1%E4%BB%8B">&#x57FA;&#x790E;&#x6982;&#x5FF5;&#x7C21;&#x4ECB;</h1><h2 id="%E5%89%8D%E8%A8%80">&#x524D;&#x8A00;</h2><img src="https://ghost.augustushsu.com/content/images/2023/10/mongodb-note-01-1.png" alt="MongoDB Note 01"><p>&#x50B3;&#x7D71;&#x7684;&#x8CC7;&#x6599;&#x5EAB;&#x4F7F;&#x7528;&#x7684;&#x662F;<code>&#x95DC;&#x806F;&#x5F0F;&#x8CC7;&#x6599;&#x5EAB;&#x7BA1;&#x7406;&#x7CFB;&#x7D71;(Relational Database Management System/RDBMS)</code>&#xFF0C;&#x9700;&#x8981;&#x5728;&#x95DC;&#x806F;&#x5F0F;&#x8CC7;&#x6599;&#x5EAB;&#x4E2D;&#x4E8B;&#x5148;&#x5B9A;&#x7FA9;&#x597D;<code>Schema(&#x7DB1;&#x8981;)</code>&#xFF1B;&#x4E5F;&#x5C31;&#x662F;&#x6BCF;&#x5F35;<code>Table(&#x8CC7;&#x6599;&#x8868;)</code>&#x4E2D;&#x5305;&#x542B;&#x54EA;&#x4E00;&#x4E9B;<code>Column(&#x6B04;&#x4F4D;)</code>&#xFF0C;&#x4E26;&#x4E14;&#x8981;&#x78BA;&#x4FDD;&#x5F8C;&#x7E8C;&#x65B0;&#x589E;&#x5132;&#x5B58;&#x7684;<code>Row(&#x8CC7;&#x6599;)</code>&#x90FD;&#x8981;&#x9075;&#x5FAA;schema&#x7684;&#x5B9A;&#x7FA9;&#x3002;</p><p>&#x9019;&#x908A;&#x8209;&#x500B;&#x4F8B;&#x5B50;&#xFF0C;&#x5982;&#x679C;&#x60F3;&#x8981;&#x5728;RDBMS&#x4E2D;&#x8A18;&#x9304;&#x6703;&#x54E1;&#x7684;&#x8CC7;&#x8A0A;&#xFF0C;&#x5982;&#x679C;&#x6700;&#x521D;&#x5B9A;&#x7FA9;<code>Product &#x8CC7;&#x6599;&#x8868;</code>&#x7684;schema&#x4E2D;&#x6709;&#x59D3;&#x540D;&#x3001;&#x8077;&#x696D;&#x3001;&#x8EAB;&#x9AD8;&#x3001;&#x9AD4;&#x91CD;&#x56DB;&#x500B;&#x6B04;&#x4F4D;&#xFF0C;&#x5247;&#x8A72;&#x8CC7;&#x6599;&#x8868;&#x4E2D;&#x7684;&#x6BCF;&#x4E00;&#x7B46;&#x8CC7;&#x6599;&#x90FD;&#x5FC5;&#x9808;&#x8981;&#x6709;&#x9019;&#x56DB;&#x500B;&#x6B04;&#x4F4D;&#xFF0C;&#x7D50;&#x679C;&#x8CC7;&#x6599;&#x8868;&#x5FEB;&#x5EFA;&#x5B8C;&#x4E86;&#x624D;&#x767C;&#x73FE;&#x5FD8;&#x8A18;&#x52A0;&#x4E0A;&#x8840;&#x578B;&#x9019;&#x500B;&#x6B04;&#x4F4D;&#xFF0C;&#x53C8;&#x6216;&#x8005;&#x5E0C;&#x671B;&#x5E6B;&#x5176;&#x4E2D;&#x4E00;&#x500B;&#x6703;&#x54E1;&#x7D00;&#x9304;&#x4E0A;&#x8208;&#x8DA3;&#xFF0C;&#x9019;&#x7A2E;&#x72C0;&#x6CC1;&#x5728;&#x95DC;&#x806F;&#x5F0F;&#x8CC7;&#x6599;&#x5EAB;&#x4E2D;&#xFF0C;&#x56E0;&#x70BA;&#x8981;&#x9075;&#x5B88;schema&#x7684;&#x5B9A;&#x7FA9;&#xFF0C;&#x6240;&#x4EE5;&#x9700;&#x8981;&#x66F4;&#x52D5;schema&#xFF0C;&#x5728;&#x6B04;&#x4F4D;&#x4E0A;&#x65B0;&#x589E;&#x8840;&#x578B;&#x3001;&#x8208;&#x8DA3;&#x6B04;&#x4F4D;&#xFF0C;&#x518D;&#x4F86;&#x5BEB;&#x4E00;&#x500B;script&#x5E6B;&#x73FE;&#x6709;&#x6240;&#x6709;&#x7684;&#x6703;&#x54E1;&#x90FD;&#x52A0;&#x4E0A;&#x8208;&#x8DA3;(&#x82E5;&#x7121;&#x53EF;&#x586B;&#x4E0A;&#x7A7A;&#x503C;)&#x3002;</p><p>&#x6BD4;&#x8D77;&#x4E0A;&#x8FF0;&#x7684;&#x60C5;&#x6CC1;&#xFF0C;&#x5C0D;&#x65BC;MongoDB&#x4F86;&#x8AAA;&#xFF0C;&#x56E0;&#x70BA;&#x5B83;&#x88AB;&#x8A2D;&#x8A08;&#x70BA;&#x4E00;&#x7A2E;&#x4EE5;<code>document</code>&#x70BA;&#x4E3B;&#x7684;database&#xFF0C;&#x6240;&#x4EE5;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x5C07;&#x8208;&#x8DA3;&#x6B04;&#x4F4D;&#x76F4;&#x63A5;&#x52A0;&#x5165;&#x5C6C;&#x65BC;&#x9019;&#x500B;&#x6703;&#x54E1;&#x7684;&#x8CC7;&#x6599;&#x5167;&#x5373;&#x53EF;&#x3002;&#x9664;&#x4E86;&#x53EF;&#x4EE5;&#x5F88;&#x5BB9;&#x6613;&#x7684;&#x589E;&#x52A0;&#x6B04;&#x4F4D;&#x5916;&#xFF0C;MongoDB&#x9084;&#x80FD;&#x900F;&#x904E;<code>Sharding</code>&#x529F;&#x80FD;&#xFF0C;&#x8F15;&#x6613;&#x5730;&#x6C34;&#x5E73;&#x64F4;&#x5C55;&#x6574;&#x9AD4;&#x7684;&#x8CC7;&#x6599;&#x5EAB;&#x5927;&#x5C0F;&#x3002;</p><div class="kg-card kg-callout-card kg-callout-card-grey"><div class="kg-callout-emoji">&#x1F4A1;</div><div class="kg-callout-text">&#x56E0;&#x70BA;MongoDB&#x4E0D;&#x9700;&#x8981;&#x5B9A;&#x7FA9;Schema (Schemaless)&#xFF0C;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x65B0;&#x589E;&#xFF0C;&#x5982;&#x6B64;&#x53EF;&#x4EE5;&#x5927;&#x5E45;&#x7E2E;&#x77ED;&#x958B;&#x767C;&#x6642;&#x9593;&#xFF0C;&#x9069;&#x5408;&#x7528;&#x65BC;&#x8CC7;&#x6599;&#x683C;&#x5F0F;&#x5E38;&#x8B8A;&#x52D5;&#x7684;&#x61C9;&#x7528;&#x4E2D;&#x3002;</div></div><h2 id="mongodb%E7%9A%84%E5%B1%A4%E7%B4%9A%E6%9E%B6%E6%A7%8B">MongoDB&#x7684;&#x5C64;&#x7D1A;&#x67B6;&#x69CB;</h2><p>MongoDB&#x7684;&#x5C64;&#x7D1A;&#x5F9E;&#x5927;&#x5230;&#x5C0F;&#x5206;&#x5225;&#x662F;<code>Database</code>&#x3001;<code>Collection</code>&#x548C;<code>Document</code>&#xFF0C;&#x4E0B;&#x9762;&#x9019;&#x5F35;&#x5716;&#x5C0D;&#x61C9;&#x4E86;MongoDB&#x548C;&#x50B3;&#x7D71;&#x95DC;&#x806F;&#x5F0F;&#x8CC7;&#x6599;&#x5EAB;<code>SQLDatabase</code>&#x7684;&#x5C0D;&#x61C9;&#x95DC;&#x4FC2;:</p><!--kg-card-begin: markdown--><table>
<thead>
<tr>
<th>SQL</th>
<th>MongoDB</th>
<th>&#x8AAA;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td>Database</td>
<td>Database</td>
<td>&#x8CC7;&#x6599;&#x5EAB;</td>
</tr>
<tr>
<td>Table</td>
<td>Collection</td>
<td>&#x8CC7;&#x6599;&#x8868;/&#x96C6;&#x5408;</td>
</tr>
<tr>
<td>Row</td>
<td>Document</td>
<td>&#x4E00;&#x7B46;&#x6578;&#x64DA;&#x7D00;&#x9304;/&#x6587;&#x6A94;</td>
</tr>
<tr>
<td>Column</td>
<td>Field</td>
<td>&#x6578;&#x64DA;&#x6B04;&#x4F4D;/&#x57DF;</td>
</tr>
<tr>
<td>Index</td>
<td>Index</td>
<td>&#x7D22;&#x5F15;</td>
</tr>
<tr>
<td>Table Joins</td>
<td></td>
<td>&#x5408;&#x4F75;&#x8CC7;&#x6599;&#x8868;/MongoDB&#x6C92;&#x6709;Join</td>
</tr>
<tr>
<td>Primary Key</td>
<td>Primary Key</td>
<td>&#x4E3B;&#x9375;</td>
</tr>
</tbody>
</table>
<!--kg-card-end: markdown--><h3 id="database">Database</h3><p>&#x4E00;&#x500B;MongoDB&#x4F3A;&#x670D;&#x5668;&#x4E2D;&#x53EF;&#x4EE5;&#x6709;&#x591A;&#x500B;&#x7368;&#x7ACB;&#x7684;<code>Database</code>&#xFF0C;&#x6BCF;&#x4E00;&#x500B;&#x90FD;&#x6709;&#x81EA;&#x5DF1;&#x7684;collection&#x548C;&#x6B0A;&#x9650;&#xFF0C;&#x5728;&#x5BE6;&#x969B;&#x4E0A;&#x7684;&#x61C9;&#x7528;&#x4E2D;&#xFF0C;&#x4E0D;&#x540C;&#x670D;&#x52D9;&#x6216;&#x662F;&#x61C9;&#x7528;&#x7684;&#x8CC7;&#x6599;&#x6703;&#x653E;&#x5728;&#x4E0D;&#x540C;&#x7684;database&#x4E2D;&#x3002;</p><p>&#x4F8B;&#x5982;&#x6709;&#x4E00;&#x5BB6;&#x516C;&#x53F8;&#x540C;&#x6642;&#x6709;A&#x548C;B&#x670D;&#x52D9;&#xFF0C;&#x5169;&#x8005;&#x7684;&#x8CC7;&#x6599;&#x662F;&#x4E0D;&#x76F8;&#x901A;&#x7684;&#xFF0C;&#x90A3;&#x5C31;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x5728;MongoDB&#x4E2D;&#x5EFA;&#x7ACB;&#x5169;&#x500B;database&#xFF0C;&#x5206;&#x5225;&#x5B58;&#x653E;&#x5169;&#x670D;&#x52D9;&#x6240;&#x9700;&#x8981;&#x5132;&#x5B58;&#x7684;&#x8CC7;&#x6599;&#x3002;</p><p>&#x8CC7;&#x6599;&#x5EAB;&#x7684;&#x540D;&#x5B57;&#x5728;MongoDB&#x4E2D;&#x6709;&#x8457;&#x4E00;&#x4E9B;&#x9650;&#x5236;:</p><ol><li>&#x4E0D;&#x80FD;&#x662F;&#x7A7A;&#x5B57;&#x4E32;</li><li>&#x4E0D;&#x53EF;&#x4EE5;&#x542B;&#x6709;&apos; &apos;(&#x7A7A;&#x683C;)&#x3001;.(&#x9EDE;)&#x3001;$(&#x9322;&#x5B57;&#x7B26;)&#x3001;/(&#x659C;&#x7DDA;)&#x3001;\(&#x53CD;&#x659C;&#x7DDA;)&#x548C;\0(&#x7A7A;&#x5B57;&#x7B26;)</li><li>&#x61C9;&#x5168;&#x70BA;&#x5C0F;&#x5BEB;</li><li>&#x6700;&#x591A;64&#x500B;&#x5B57;&#x5143;</li></ol><p>&#x6B64;&#x5916;&#xFF0C;&#x6709;&#x4E00;&#x4E9B;database&#x7684;&#x540D;&#x7A31;&#x662F;&#x5EFA;&#x7ACB;&#x6642;&#x5C31;&#x9810;&#x8A2D;&#x5B58;&#x5728;&#x7684;&#xFF0C;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x9023;&#x7D50;&#x9032;&#x884C;&#x67E5;&#x770B;:</p><ul><li><strong>admin</strong><br>MongoDB&#x6703;&#x5C07;&#x6240;&#x6709;&#x4F7F;&#x7528;&#x8005;&#x7684;&#x8CC7;&#x8A0A;&#x5132;&#x5B58;&#x5728;&#x9019;&#x500B;database(&#x540D;&#x7A31;&#x3001;&#x5BC6;&#x78BC;&#x548C;&#x4F7F;&#x7528;&#x8005;&#x7684;&#x9A57;&#x8B49;&#x8CC7;&#x6599;&#x5EAB;)&#xFF0C;&#x5982;&#x679C;&#x8981;&#x5EFA;&#x7ACB;&#x500B;&#x5225;database&#x7684;&#x4F7F;&#x7528;&#x8005;&#xFF0C;&#x5728;&#x500B;&#x5225;&#x7684;database&#x4E2D;&#x5EFA;&#x7ACB;&#x5373;&#x53EF;&#xFF0C;&#x4F46;&#x5982;&#x679C;&#x8981;&#x8DE8;database&#x4F7F;&#x7528;&#xFF0C;&#x5247;&#x9700;&#x8981;&#x5728;&#x9019;&#x500B;&#x8CC7;&#x6599;&#x5EAB;&#x4E2D;&#x5EFA;&#x7ACB;&#xFF0C;&#x6703;&#x81EA;&#x52D5;&#x7E7C;&#x627F;&#x5230;&#x5176;&#x4ED6;database&#xFF0C;&#x95DC;&#x65BC;&#x7BA1;&#x7406;&#x4F7F;&#x7528;&#x8005;&#x7684;&#x65B9;&#x6CD5;&#x6703;&#x5728;&#x984D;&#x5916;&#x767C;&#x4E00;&#x7BC7;&#x4ECB;&#x7D39;&#x3002;</li><li><strong>local</strong><br>&#x9019;&#x500B;database&#x6C38;&#x9060;&#x4E0D;&#x6703;&#x88AB;&#x8907;&#x88FD;&#xFF0C;&#x7528;&#x4F86;&#x5132;&#x5B58;&#x9019;&#x53F0;&#x6A5F;&#x5668;&#x7684;&#x6A94;&#x6848;&#x548C;&#x8CC7;&#x8A0A;&#xFF0C;&#x4E0D;&#x6703;&#x56E0;&#x70BA;&#x5EFA;&#x7ACB;&#x1F4A1;<strong>replica set</strong>(&#x5EFA;&#x7ACB;&#x526F;&#x672C;&#xFF0C;&#x9810;&#x9632;MongoDB&#x639B;&#x6389;&#x800C;&#x5C0E;&#x81F4;&#x670D;&#x52D9;&#x639B;&#x6389;)&#x8907;&#x88FD;&#x9019;&#x500B;database&#x7684;&#x8CC7;&#x6599;&#x3002;</li><li><strong>config</strong><br>&#x4E3B;&#x8981;&#x5B58;&#x653E;<code>Sharding</code>&#x76F8;&#x95DC;&#x7684;&#x8CC7;&#x6599;&#xFF0C;&#x5728;3.6&#x7248;&#x672C;&#x4EE5;&#x5F8C;&#xFF0C;&#x6703;&#x5132;&#x5B58;standalone&#x6216;&#x662F;replication&#x8CC7;&#x6599;&#xFF0C;&#x4E5F;&#x6709;&#x8DDF;transaction&#x76F8;&#x95DC;&#x7684;&#x8CC7;&#x6599;&#xFF0C;&#x4F46;&#x662F;&#x7981;&#x6B62;&#x53BB;&#x91DD;&#x5C0D;&#x9019;&#x500B;database&#x9032;&#x884C;&#x4FEE;&#x6539;&#x6216;&#x522A;&#x9664;&#xFF0C;&#x50C5;&#x53EF;&#x4EE5;&#x67E5;&#x770B;&#x3002;<br>&#x7576;MongoDB&#x4F7F;&#x7528;<code>Sharding</code>&#x6642;&#xFF0C;config database&#x6703;&#x5728;&#x5167;&#x90E8;&#x4F7F;&#x7528;&#xFF0C;&#x7528;&#x65BC;&#x4FDD;&#x5B58;sharding&#x7684;&#x76F8;&#x95DC;&#x8CC7;&#x8A0A;&#x3002;</li></ul><div class="kg-card kg-callout-card kg-callout-card-grey"><div class="kg-callout-emoji">&#x1F4A1;</div><div class="kg-callout-text">Replica Set&#x70BA;&#x8FD1;&#x5E74;&#x591A;&#x6578;&#x8CC7;&#x6599;&#x5EAB;&#x6240;&#x4F7F;&#x7528;&#x7684;&#x67B6;&#x69CB;&#xFF0C;&#x4EE5;Primary&#x548C;Secondary&#x4F86;&#x53D6;&#x4EE3;&#x820A;&#x6709;&#x7684;Master&#x548C;Slave&#x67B6;&#x69CB;&#xFF0C;&#x5177;&#x6709;&#x81EA;&#x52D5;&#x6545;&#x969C;&#x6062;&#x5FA9;&#x3001;&#x8B80;&#x5BEB;&#x63A7;&#x5236;&#x7B49;&#x7B49;&#x512A;&#x52E2;&#x3002;</div></div><p>&#x5EFA;&#x7ACB;database&#x7684;&#x65B9;&#x6CD5;&#x5F88;&#x7C21;&#x55AE;&#xFF0C;&#x76F4;&#x63A5;&#x4F7F;&#x7528;<code>use</code>&#x5373;&#x53EF;&#x5207;&#x63DB;&#x5230;&#x6307;&#x5B9A;&#x7684;database&#xFF0C;&#x5982;&#x679C;&#x5728;MongoDB&#x4E2D;&#x6C92;&#x6709;&#x8A72;database&#x5247;&#x6703;&#x76F4;&#x63A5;&#x5EFA;&#x7ACB;&#x4E00;&#x500B;&#x65B0;&#x7684;:</p><pre><code class="language-cmd">&gt; show dbs
admin   0.000GB
config  0.000GB
local   0.000GB
&gt; use testDataset
switched to db testDataset</code></pre><h3 id="collection">Collection</h3><p><code>Collection</code>&#x76F8;&#x7576;&#x65BC;&#x95DC;&#x806F;&#x5F0F;&#x8CC7;&#x6599;&#x5EAB;&#x7684; Table&#x7684;&#x6982;&#x5FF5;&#xFF0C;&#x4E3B;&#x8981;&#x5DEE;&#x5225;&#x5728;&#x5B83;&#x5B58;&#x653E;&#x7684;&#x662F;document&#x800C;&#x975E;&#x56FA;&#x5B9A;&#x5927;&#x5C0F;&#x3001;&#x683C;&#x5F0F;&#x7684;record&#xFF0C;&#x901A;&#x5E38;&#x4E00;&#x500B; databse &#x4E2D;&#x6703;&#x6709;&#x6578;&#x500B; collection&#x3002;</p><p>&#x4EE5;database&#x4E0A;&#x7684;&#x4F8B;&#x5B50;&#x4F86;&#x8AAA;&#x5982;&#x679C;&#x670D;&#x52D9; A&#x70BA;&#x4E00;&#x500B;&#x92B7;&#x552E;&#x8CC7;&#x6599;&#x5EAB;&#xFF0C;&#x53EF;&#x80FD;&#x6703;&#x60F3;&#x8981;&#x5206;&#x5225;&#x8A18;&#x9304;&#x300C;&#x8CFC;&#x8CB7;&#x4EBA;&#x8CC7;&#x8A0A;&#x300D;&#x3001;&#x300C;&#x88FD;&#x9020;&#x5546;&#x8CC7;&#x8A0A;&#x300D;&#x3001;&#x300C;&#x8CA9;&#x552E;&#x5730;&#x9EDE;&#x300D;...&#x7B49;&#x7B49;&#xFF0C;&#x56E0;&#x6B64;&#x53EF;&#x4EE5;&#x5728;&#x300C;&#x7522;&#x54C1; A &#x7684; database&#x300D; &#x4E2D;&#x5206;&#x5225;&#x958B;&#x8A2D;&#x5C0D;&#x61C9;&#x7684; collection&#x3002;</p><p>&#x540C;&#x6642;&#x56E0;&#x70BA;MongoDB&#x6C92;&#x6709;&#x56FA;&#x5B9A;&#x7684;&#x7D50;&#x69CB;&#xFF0C;&#x6240;&#x4EE5;&#x9084;&#x53EF;&#x4EE5;&#x91DD;&#x5C0D;&#x7279;&#x5B9A;&#x7684;&#x8CC7;&#x6599;&#x8A2D;&#x8A08;&#x4E0D;&#x540C;&#x7684;&#x7D50;&#x69CB;&#xFF0C;&#x4F46;&#x540C;&#x6642;&#x90FD;&#x662F;&#x5C6C;&#x65BC;&#x540C;&#x4E00;&#x500B;collection&#x3002;</p><p>&#x4F8B;&#x5982;&#x4EE5;&#x300C;&#x8CFC;&#x8CB7;&#x4EBA;&#x8CC7;&#x8A0A;&#x300D;&#x70BA;&#x4F8B;&#xFF0C;&#x53EF;&#x4EE5;&#x53EA;&#x91DD;&#x5C0D;&#x7279;&#x5B9A;&#x7684;user&#x589E;&#x52A0;&#x8208;&#x8DA3;&#x7684;&#x6B04;&#x4F4D;&#xFF0C;&#x800C;&#x5176;&#x4ED6;&#x7684;user&#x5247;&#x5B8C;&#x5168;&#x4E0D;&#x53D7;&#x5F71;&#x97FF;:</p><pre><code class="language-JSON">{
    &quot;name&quot;: &apos;Stank&apos;,
    &quot;job&quot;: &apos;software engineer&apos;,
    &quot;bloodType&quot;: &apos;A&apos;
}
{
    &quot;name&quot;: &apos;Augustus&apos;,
    &quot;job&quot;: &apos;software engineer&apos;,
    &quot;bloodType&quot;: &apos;O&apos;,
    &quot;hobbies&quot;: [&apos;sleeping&apos;, &apos;computer game&apos;, &apos;guitar&apos;],
}</code></pre><h3 id="document">Document</h3><p><code>Document</code>&#x5C31;&#x662F;&#x4E00;&#x7B46;&#x8CC7;&#x6599;&#xFF0C;&#x6982;&#x5FF5;&#x597D;&#x6BD4;&#x95DC;&#x806F;&#x5F0F;&#x8CC7;&#x6599;&#x5EAB;&#x7684;Row&#x3002;&#x901A;&#x5E38;&#x4E00;&#x500B;collection&#x4E2D;&#x6703;&#x6709;&#x6578;&#x7B46;document&#x3002;&#x4E5F;&#x56E0;&#x6B64;&#x6211;&#x5011;&#x7A31;MongoDB&#x662F;<code>document database</code>&#x3002;</p><p>&#x4F8B;&#x5982;&#x5728;&#x300C;&#x8CFC;&#x8CB7;&#x4EBA;&#x8CC7;&#x8A0A;&#x300D;&#x7684;collection&#x4E2D;&#xFF0C;&#x771F;&#x6B63;&#x7684;&#x4E00;&#x7B46;&#x300C;&#x8CFC;&#x8CB7;&#x4EBA;&#x8CC7;&#x8A0A;&#x300D;&#x5C31;&#x662F;&#x4E00;&#x500B;document&#x3002;</p><p>&#x4EE5;&#x4E0B;&#x662F;Document&#x7684;&#x4F8B;&#x5B50;&#xFF0C;&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x9577;&#x7684;&#x8DDF;JSON&#x4E00;&#x6A23;&#xFF0C;&#x7531;&#x591A;&#x7D44;&#x7684;key-value&#x7D44;&#x6210;&#xFF0C;&#x4E0D;&#x904E;&#x5728;MongoDB&#x4E2D;&#x662F;&#x4F7F;&#x7528;field&#x9019;&#x500B;&#x540D;&#x7A31;:</p><pre><code class="language-json">{
    &quot;name&quot;: &quot;Augustus&quot;,               &lt;----field:value
    &quot;age&quot;: 26,                        &lt;----field:value
    &quot;status&quot;: &quot;S&quot;,                    &lt;----field:value
    &quot;groups&quot;: [&quot;MongoDB&quot;, &quot;GitLab&quot;]   &lt;----field:value
}</code></pre><h2 id="mongodb%E5%84%B2%E5%AD%98%E6%A0%BC%E5%BC%8F-bson">MongoDB&#x5132;&#x5B58;&#x683C;&#x5F0F; (BSON)</h2><p>MongoDB&#x6BCF;&#x7B46;document&#x90FD;&#x662F;&#x50CF;JSON&#x683C;&#x5F0F;&#x7684;key-value&#x7D44;&#x5408;&#xFF0C;&#x4F46;&#x5BE6;&#x969B;&#x4E0A;MongoDB&#x5728;&#x5132;&#x5B58;&#x8CC7;&#x6599;&#x7684;&#x683C;&#x5F0F;&#x662F;<code>BSON</code>(Binary JSON&#xFF0C;JSON&#x4E8C;&#x9032;&#x4F4D;&#x8868;&#x793A;&#x5F62;&#x5F0F;)&#xFF0C;&#x4F7F;&#x7528;BSON&#x7684;&#x512A;&#x9EDE;&#x5728;&#x65BC;&#x5728;&#x7A7A;&#x9593;&#x4E0A;&#x5132;&#x5B58;&#x8F03;&#x6709;&#x6548;&#x7387;&#xFF0C;BSON&#x652F;&#x63F4;&#x7684;&#x683C;&#x5F0F;&#x53EF;&#x4EE5;&#x53C3;&#x8003;<a href="https://www.mongodb.com/docs/manual/reference/bson-types/?ref=ghost.augustushsu.com">&#x5B98;&#x7DB2;</a>&#xFF0C;&#x9019;&#x88E1;&#x4ECB;&#x7D39;&#x4E00;&#x4E9B;&#x6BD4;&#x8F03;&#x7279;&#x5225;&#x7684;&#x683C;&#x5F0F;:</p><ul><li>binData<br>&#x5132;&#x5B58;&#x4E8C;&#x9032;&#x5236;&#x7684;&#x8CC7;&#x6599;(binary data)&#x3002;</li><li>timestamp &amp; date<br>timestamp&#x548C;date&#x4E00;&#x6A23;&#x662F;&#x5132;&#x5B58;&#x6642;&#x9593;&#x7684;&#x8CC7;&#x6599;&#xFF0C;&#x4F46;&#x662F;date&#x5728;&#x8DE8;&#x6642;&#x5340;&#x7684;&#x6642;&#x5019;&#x6703;&#x6709;&#x9700;&#x8981;&#x8F49;&#x63DB;&#x6642;&#x5340;&#x7684;&#x554F;&#x984C;&#x7522;&#x751F;&#x3002;</li><li>object<br>&#x53EF;&#x4EE5;&#x5728;&#x9019;&#x500B;&#x6B04;&#x4F4D;&#x4E2D;&#x63D2;&#x5165;document&#xFF0C;&#x53EF;&#x4EE5;&#x60F3;&#x50CF;&#x6210;&#x6587;&#x4EF6;&#x4E2D;&#x7684;&#x5B50;&#x6587;&#x4EF6;&#xFF0C;&#x5982;&#x4E0B;&#x7BC4;&#x4F8B;&#x7684;<code>livein</code>&#x6B04;&#x4F4D;:</li></ul><pre><code class="language-json">{
    &quot;name&quot;: &apos;Augustus&apos;,
    &quot;job&quot;: &apos;software engineer&apos;,
    &quot;bloodType&quot;: &apos;O&apos;,
    &quot;hobbies&quot;: [&apos;sleeping&apos;, &apos;computer game&apos;, &apos;guitar&apos;],
    &quot;livein&quot;:
    {
        &quot;contry&quot;: &apos;Taiwan&apos;,
        &quot;city&quot;: &apos;Taipei&apos;
    }
}</code></pre><ul><li>regex<br>&#x7528;&#x4F86;&#x5132;&#x5B58;&#x6B63;&#x5247;&#x8868;&#x9054;&#x5F0F;&#x3002;</li><li>javascript<br>&#x7528;&#x4F86;&#x5132;&#x5B58;<code>javascript</code>&#x8A9E;&#x6CD5;&#x3002;</li><li>objectId<br>&#x6703;&#x5728;&#x6587;&#x7AE0;&#x4E0B;&#x9762;&#x63D0;&#x5230;&#x3002;</li></ul><h3 id="objectid">objectId</h3><p>MongoDB&#x7684;&#x6838;&#x5FC3;&#xFF0C;&#x53EF;&#x4EE5;&#x900F;&#x904E;&#x9019;&#x500B;id&#x76F4;&#x63A5;&#x8655;&#x7406;document&#xFF0C;&#x4EE5;&#x4E0B;&#x662F;objectId&#x7684;&#x5E7E;&#x500B;&#x7279;&#x6027;:</p><ul><li>&#x9810;&#x8A2D;&#x6BCF;&#x4E00;&#x500B;&#x6587;&#x4EF6;&#x90FD;&#x6709;&#x7684;&#x6B04;&#x4F4D;(&#x9023;object&#x578B;&#x614B;&#x7684;&#x8CC7;&#x6599;&#x90FD;&#x6703;&#x6709;)</li><li>&#x5982;&#x679C;&#x6C92;&#x6709;&#x8A2D;&#x5B9A;&#xFF0C;&#x6703;&#x81EA;&#x52D5;&#x7522;&#x751F;&#x9019;&#x500B;&#x6B04;&#x4F4D;</li><li>&#x6BCF;&#x4E00;&#x500B;&#x6587;&#x4EF6;&#x7684;&#x552F;&#x4E00;&#x4F4D;&#x7F6E;</li><li>&#x7CFB;&#x7D71;&#x9810;&#x8A2D;&#x7684;single index key</li><li>collection&#x5C64;&#x7D1A;&#x7684;&#x552F;&#x4E00;&#x503C;</li><li>&#x8CC7;&#x6599;&#x884C;&#x5225;&#x70BA;<code>ObjectId</code></li></ul><p>&#x4EE5;&#x4E0B;&#x662F;&#x4E00;&#x500B;objectId&#x7684;&#x4F8B;&#x5B50;:</p><pre><code class="language-json">db.costumer.insertOne({ ... })

db.costumer.find()

{
    &quot;_id&quot; : ObjectId(&quot;62d511895ddbc92df38d37e3&quot;),
    &quot;name&quot;: &apos;Augustus&apos;,
    &quot;job&quot;: &apos;software engineer&apos;,
    &quot;bloodType&quot;: &apos;O&apos;,
    &quot;hobbies&quot;: [&apos;sleeping&apos;, &apos;computer game&apos;, &apos;guitar&apos;],
    &quot;livein&quot;:
    {
        &quot;contry&quot;: &apos;Taiwan&apos;,
        &quot;city&quot;: &apos;Taipei&apos;
    }
}
    </code></pre><p>&#x7CFB;&#x7D71;&#x5982;&#x4F55;&#x751F;&#x6210;objectId&#x7684;&#x76F8;&#x95DC;&#x6587;&#x6A94;<a href="https://github.com/mongodb/specifications/blob/master/source/objectid.rst?ref=ghost.augustushsu.com#specification">&#x5728;&#x9019;</a>&#x53EF;&#x4EE5;&#x770B;&#x5230;&#xFF0C;&#x53E6;&#x5916;objectId&#x4E5F;&#x53EF;&#x4EE5;&#x81EA;&#x884C;&#x5B9A;&#x7FA9;&#xFF0C;&#x5176;&#x4ED6;&#x578B;&#x5225;&#x4E5F;&#x53EF;&#x4EE5;&#x62FF;&#x4F86;&#x505A;&#x70BA;<strong>_id&#xFF0C;</strong>&#x4F46;&#x662F;&#x9700;&#x8981;&#x78BA;&#x4FDD;<strong>_id</strong>&#x5728;collection&#x5C64;&#x7D1A;&#x4E0A;&#x7684;&#x552F;&#x4E00;&#x6027;&#x3002;</p><h2 id="mongodb%E5%84%AA%E7%BC%BA%E9%BB%9E%E6%AF%94%E8%BC%83">MongoDB&#x512A;&#x7F3A;&#x9EDE;&#x6BD4;&#x8F03;</h2><!--kg-card-begin: markdown--><table>
<thead>
<tr>
<th>&#x512A;&#x9EDE;</th>
<th>&#x7F3A;&#x9EDE;</th>
</tr>
</thead>
<tbody>
<tr>
<td>&#x9748;&#x6D3B;&#x7684;&#x6578;&#x64DA;&#x6A21;&#x578B;</td>
<td>&#x9700;&#x8981;&#x66F4;&#x591A;&#x7684;&#x5132;&#x5B58;&#x7A7A;&#x9593;</td>
</tr>
<tr>
<td>&#x5927;&#x90E8;&#x5206;&#x53EF;&#x5DE5;&#x4F5C;&#x7684;&#x6578;&#x64DA;&#x5132;&#x5B58;&#x5728;RAM</td>
<td>RAM&#x7684;&#x4F7F;&#x7528;&#x6703;&#x7206;&#x9AD8;</td>
</tr>
<tr>
<td>&#x53EF;&#x6C34;&#x5E73;&#x64F4;&#x5C55; (Sharding&#x652F;&#x63F4;20PB)</td>
<td>&#x5F31;&#x4E00;&#x81F4;&#x6027; (&#x6700;&#x7D42;&#x4E00;&#x81F4;)&#xFF0C;&#x6C92;&#x6709;&#x1F4A1;<strong>ACID&#x4FDD;&#x8B49;</strong></td>
</tr>
<tr>
<td></td>
<td>&#x6C92;&#x6709;Triger</td>
</tr>
<tr>
<td>&#x6587;&#x6A94;=&#x7269;&#x4EF6;&#xFF0C;&#x4E0D;&#x9700;&#x8981;ORM(&#x7269;&#x4EF6;&#x95DC;&#x4FC2;&#x5C0D;&#x6620;)</td>
<td>&#x91CD;&#x8907;&#x7684;&#x6578;&#x64DA;</td>
</tr>
<tr>
<td>&#x7D22;&#x5F15;(index)</td>
<td>&#x7D22;&#x5F15;(index)</td>
</tr>
<tr>
<td></td>
<td>&#x4E0D;&#x652F;&#x63F4;Join</td>
</tr>
</tbody>
</table>
<!--kg-card-end: markdown--><div class="kg-card kg-callout-card kg-callout-card-grey"><div class="kg-callout-emoji">&#x1F4A1;</div><div class="kg-callout-text"><strong>ACID&#xFF0C;&#x662F;&#x6307;&#x8CC7;&#x6599;&#x5EAB;&#x7BA1;&#x7406;&#x7CFB;&#x7D71;&#xFF08;DBMS&#xFF09;&#x5728;&#x5BEB;&#x5165;&#x6216;&#x66F4;&#x65B0;&#x8CC7;&#x6599;&#x7684;&#x904E;&#x7A0B;&#x4E2D;&#xFF0C;&#x70BA;&#x4FDD;&#x8B49;&#x4E8B;&#x52D9;&#xFF08;transaction&#xFF09;&#x662F;&#x6B63;&#x78BA;&#x53EF;&#x9760;&#x7684;&#xFF0C;&#x6240;&#x5FC5;&#x9808;&#x5177;&#x5099;&#x7684;&#x56DB;&#x500B;&#x7279;&#x6027;&#xFF1A;&#x539F;&#x5B50;&#x6027;&#xFF08;atomicity&#xFF0C;&#x6216;&#x7A31;&#x4E0D;&#x53EF;&#x5206;&#x5272;&#x6027;&#xFF09;&#x3001;&#x4E00;&#x81F4;&#x6027;&#xFF08;consistency&#xFF09;&#x3001;&#x9694;&#x96E2;&#x6027;&#xFF08;isolation&#xFF0C;&#x53C8;&#x7A31;&#x7368;&#x7ACB;&#x6027;&#xFF09;&#x3001;&#x6301;&#x4E45;&#x6027;&#xFF08;durability&#xFF09;&#x3002;</strong></div></div><h2 id="mongodb%E5%AF%A6%E5%8B%99%E5%B1%A4%E9%9D%A2%E4%B8%8A%E7%9A%84%E5%95%8F%E9%A1%8C">MongoDB&#x5BE6;&#x52D9;&#x5C64;&#x9762;&#x4E0A;&#x7684;&#x554F;&#x984C;</h2><p>&#x5728;&#x4F7F;&#x7528;MongoDB&#x4E4B;&#x524D;&#x6709;&#x67E5;&#x8A62;&#x5230;MongoDB&#x5728;&#x5BE6;&#x969B;&#x4F7F;&#x7528;&#x4E0A;&#x7684;&#x4E00;&#x4E9B;&#x554F;&#x984C;:</p><ol><li>Aggregation&#x67E5;&#x8A62;&#x5728;&#x6A6B;&#x8DE8;&#x591A;&#x500B;Database&#x3001;&#x591A;&#x500B;Collection&#x6642;&#x6703;&#x8B8A;&#x6162;&#x5F88;&#x591A;<br>&#x9700;&#x8981;&#x6709;&#x8A2D;&#x8A08;&#x826F;&#x597D;&#x7684;Database&#x548C;Collection&#x624D;&#x80FD;&#x78BA;&#x4FDD;&#x64C1;&#x6709;&#x5FEB;&#x901F;&#x7684;&#x67E5;&#x8A62;&#x901F;&#x5EA6;</li><li>&#x5F8C;&#x671F;&#x6548;&#x80FD;&#x554F;&#x984C;: <br>&#x767E;G&#x4EE5;&#x4E0A;&#x7684;&#x8CC7;&#x6599;&#xFF0C;&#x9700;&#x8981;&#x6709;&#x826F;&#x597D;&#x7684;index&#x8A2D;&#x8A08;&#x4F86;&#x63D0;&#x901F;<br>ex.&#x8CC7;&#x6599;&#x5EAB;&#x5167;&#x6709;&#x5341;&#x842C;&#x689D;6000&#x5B57;&#x6587;&#x672C;&#x5F8C;&#xFF0C;&#x67E5;&#x8A62;&#x901F;&#x5EA6;&#x964D;&#x4F4E;</li></ol><h2 id="%E7%B5%90%E8%AB%96">&#x7D50;&#x8AD6;</h2><p>MongoDB&#x5F37;&#x52E2;&#x7684;&#x5730;&#x65B9;&#x5728;&#x65BC;&#x5132;&#x5B58;&#x8CC7;&#x6599;&#x7684;&#x683C;&#x5F0F;&#x5F48;&#x6027;&#xFF0C;&#x7531;&#x65BC;&#x5C6C;&#x65BC;NoSQL&#x4E0D;&#x9700;&#x8981;&#x5B9A;&#x7FA9;Schema&#xFF0C;&#x53EF;&#x4EE5;&#x8F15;&#x6613;&#x7684;&#x65B0;&#x589E;&#x3001;&#x4FEE;&#x6539;&#x8CC7;&#x6599;&#xFF0C;&#x5C0D;&#x65BC;&#x525B;&#x958B;&#x59CB;&#x4F7F;&#x7528;&#x8CC7;&#x6599;&#x5EAB;&#xFF0C;&#x8CC7;&#x6599;&#x7684;&#x683C;&#x5F0F;&#x9084;&#x6C92;&#x5B9A;&#x4E0B;&#x4F86;&#x7684;&#x61C9;&#x7528;&#x5341;&#x5206;&#x53CB;&#x5584;&#xFF0C;&#x5728;&#x6548;&#x80FD;&#x65B9;&#x9762;&#x4E5F;&#x662F;&#x76F8;&#x7576;&#x5FEB;&#x901F;&#xFF0C;&#x53C8;&#x56E0;&#x70BA;&#x53EF;&#x4EE5;&#x5FEB;&#x901F;&#x7684;&#x6C34;&#x5E73;&#x64F4;&#x5F35;&#xFF0C;&#x5728;&#x5927;&#x6578;&#x64DA;&#x7684;&#x61C9;&#x7528;&#x4E0A;&#x4E5F;&#x662F;&#x76F8;&#x7576;&#x65B9;&#x4FBF;&#x3002;</p>]]></content:encoded></item><item><title><![CDATA[Ghost Blog Note 02]]></title><description><![CDATA[記錄從Github下載後更動過可能會影響到視覺效果的所有內容。]]></description><link>https://ghost.augustushsu.com/ghost-blog-note-02/</link><guid isPermaLink="false">64f611cce8930f09cb6584bd</guid><category><![CDATA[Ghost-Blog-Note]]></category><dc:creator><![CDATA[AugustusHsu]]></dc:creator><pubDate>Sun, 29 Oct 2023 12:00:21 GMT</pubDate><media:content url="https://ghost.augustushsu.com/content/images/2023/09/ghost-blog-note02-cover-1.png" medium="image"/><content:encoded><![CDATA[<h1 id="%E7%B4%80%E9%8C%84casper-theme%E7%9A%84%E6%9B%B4%E5%8B%95-%E4%B8%80">&#x7D00;&#x9304;Casper Theme&#x7684;&#x66F4;&#x52D5; (&#x4E00;)</h1>
<img src="https://ghost.augustushsu.com/content/images/2023/09/ghost-blog-note02-cover-1.png" alt="Ghost Blog Note 02"><p>&#x9019;&#x500B;Blog&#x4F7F;&#x7528;&#x7684;&#x4E3B;&#x984C;&#x70BA;<a href="https://github.com/TryGhost/Casper?ref=ghost.augustushsu.com">Casper</a> (5.7.0)&#xFF0C;&#x9019;&#x7BC7;&#x4E3B;&#x8981;&#x662F;&#x8981;&#x8A18;&#x9304;&#x5F9E;Github&#x4E0B;&#x8F09;&#x5F8C;&#x66F4;&#x52D5;&#x904E;&#x53EF;&#x80FD;&#x6703;&#x5F71;&#x97FF;&#x5230;&#x8996;&#x89BA;&#x6548;&#x679C;&#x7684;&#x6240;&#x6709;&#x5167;&#x5BB9;&#x3002;</p>
<h2 id="collection%E5%8A%9F%E8%83%BD">Collection&#x529F;&#x80FD;</h2>
<p>Collection&#x6216;&#x662F;&#x53EB;Categories&#x4E5F;&#x53EF;&#x4EE5;&#xFF0C;&#x4E3B;&#x8981;&#x76EE;&#x7684;&#x662F;&#x7528;&#x6587;&#x7AE0;&#x7684;Tag&#x4F86;&#x5340;&#x5206;&#x5404;&#x500B;&#x4E3B;&#x984C;&#xFF0C;&#x4E0D;&#x904E;&#x9019;&#x88E1;&#x8981;&#x6CE8;&#x610F;&#x6211;&#x7684;&#x65B9;&#x6CD5;&#x662F;<strong>&#x76F4;&#x63A5;&#x5217;&#x51FA;&#x4F7F;&#x7528;&#x7684;Tag</strong>&#xFF0C;&#x63A5;&#x8457;&#x628A;&#x5B83;&#x5B58;&#x6210;<code>collection.hbs</code>&#x653E;&#x5728;&#x4E3B;&#x984C;&#x7684;&#x7A0B;&#x5F0F;&#x78BC;&#x4E2D;&#x5373;&#x53EF;:</p>
<pre><code class="language-handlebars">{{!&lt; default}}
{{!-- The tag above means - insert everything in this file into the {body} of the default.hbs template --}}

&lt;main id=&quot;site-main&quot; class=&quot;site-main outer&quot;&gt;
&lt;div class=&quot;inner posts&quot;&gt;
    &lt;div class=&quot;post-feed&quot;&gt;

        {{#get &apos;tags&apos; limit=&apos;all&apos; include=&apos;count.posts&apos; order=&apos;count.posts desc&apos;}}
            {{#foreach tags}}
            
                &lt;section class=&quot;post-card post-card-large&quot;&gt;
                    {{#if feature_image}}
                    &lt;div class=&quot;post-card-image-link&quot;&gt;
                        {{!-- This is a responsive image, it loads different sizes depending on device
                        https://medium.freecodecamp.org/a-guide-to-responsive-images-with-ready-to-use-templates-c400bd65c433 --}}
                        &lt;img class=&quot;post-card-image&quot;
                            srcset=&quot;{{img_url feature_image size=&quot;s&quot;}} 300w,
                                    {{img_url feature_image size=&quot;m&quot;}} 600w,
                                    {{img_url feature_image size=&quot;l&quot;}} 1000w,
                                    {{img_url feature_image size=&quot;xl&quot;}} 2000w&quot;
                            sizes=&quot;(max-width: 1000px) 400px, 800px&quot;
                            src=&quot;{{img_url feature_image size=&quot;m&quot;}}&quot;
                            alt=&quot;{{title}}&quot;
                        /&gt;
                    &lt;/div&gt;
                    {{/if}}

                    &lt;div class=&quot;post-card-content&quot;&gt;
                        &lt;div class=&quot;post-card-content-link&quot;&gt;
                            &lt;header class=&quot;post-card-header&quot;&gt;
                                    &lt;h2 class=&quot;post-card-title&quot;&gt;
                                        &lt;a href=&quot;{{url}}&quot; style=&quot;color: white; white-space: nowrap;&quot;&gt;{{name}} &lt;/a&gt;
                                    &lt;/h2&gt;
                                    &lt;div class=&quot;post-card-excerpt&quot;&gt;
                                    {{#if description}}
                                        {{description}}
                                    {{else}}
                                        {{!-- A collection of {{count.posts}}  --}}
                                        A collection of {{plural count.posts empty=&apos;zero posts&apos; singular=&apos;% post&apos; plural=&apos;% posts&apos;}}
                                    {{/if}}
                                    &lt;/div&gt;
                            &lt;/header&gt;
                        &lt;/div&gt;
                    &lt;/div&gt;
                &lt;/section&gt;

                {{#get &quot;posts&quot; filter=&quot;tag:{{slug}}&quot; include=&quot;tags,authors&quot; order=&quot;published_at desc&quot;}}
                    {{#foreach posts}}
                        {{!-- The tag below includes the markup for each post - partials/post-card.hbs --}}
                        {{&gt; &quot;post-card&quot;}}
                    {{/foreach}}
                {{/get}}

            {{/foreach}}
        {{/get}}
    &lt;/div&gt;
&lt;/div&gt;
&lt;/main&gt;</code></pre>
<div class="kg-card kg-file-card"><a class="kg-file-card-container" href="https://ghost.augustushsu.com/content/files/2023/09/collection.hbs" title="Download" download><div class="kg-file-card-contents"><div class="kg-file-card-title">collection&#x9801;&#x9762;</div><div class="kg-file-card-caption">&#x5B8C;&#x6574;&#x7684;collection.hbs&#x53EF;&#x4EE5;&#x53C3;&#x8003;&#x9019;&#x500B;&#x6A94;&#x6848;</div><div class="kg-file-card-metadata"><div class="kg-file-card-filename">collection.hbs</div><div class="kg-file-card-filesize">3 KB</div></div></div><div class="kg-file-card-icon"><svg viewbox="0 0 24 24"><defs><style>.a{fill:none;stroke:currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:1.5px;}</style></defs><title>download-circle</title><polyline class="a" points="8.25 14.25 12 18 15.75 14.25"/><line class="a" x1="12" y1="6.75" x2="12" y2="18"/><circle class="a" cx="12" cy="12" r="11.25"/></svg></div></a></div>
<p>&#x5EFA;&#x7ACB;&#x597D;<code>collection.hbs</code>&#x4E5F;&#x8981;&#x66F4;&#x6539;<code>routes.yaml</code>&#x7684;&#x8A2D;&#x5B9A;&#xFF0C;&#x5728;Settings &gt; Labs &gt; Routes&#x53EF;&#x4EE5;&#x4E0B;&#x8F09;&#x76EE;&#x524D;&#x7684;&#x8A2D;&#x5B9A;&#xFF0C;&#x66F4;&#x6539;&#x5982;&#x4E0B;:</p>
<pre><code class="language-yaml">routes:
  /collection/: collection

collections:
  /:
    permalink: /{slug}/
    template: index

taxonomies:
  tag: /tag/{slug}/
  author: /author/{slug}/
</code></pre>
<p>&#x5728;Settings &gt; Navigation&#x65B0;&#x589E;Collection&#x9801;&#x9762;&#x5C0D;&#x61C9;&#x7684;&#x7DB2;&#x5740;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/09/image.png" class="kg-image" alt="Ghost Blog Note 02" loading="lazy" width="1395" height="420" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/09/image.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2023/09/image.png 1000w, https://ghost.augustushsu.com/content/images/2023/09/image.png 1395w" sizes="(min-width: 720px) 720px"></figure>
<h2 id="code-highlight">Code Highlight</h2>
<p>&#x958B;&#x555F;Settings &gt; Code injection&#xFF0C;&#x5728;Site Header&#x4E0B;&#x7684;&#x65B9;&#x6846;&#x8F38;&#x5165;&#x4EE5;&#x4E0B;&#x7A0B;&#x5F0F;&#x78BC;:</p>
<pre><code class="language-handlebars">&lt;!-- code block --&gt;
&lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdnjs.cloudflare.com/ajax/libs/prism/1.28.0/themes/prism-tomorrow.min.css&quot; integrity=&quot;sha512-vswe+cgvic/XBoF1OcM/TeJ2FW0OofqAVdCZiEYkd6dwGXthvkSFWOoGGJgS2CW70VK5dQM5Oh+7ne47s74VTg==&quot; crossorigin=&quot;anonymous&quot; referrerpolicy=&quot;no-referrer&quot; /&gt;
</code></pre>
<p>&#x4E00;&#x6A23;&#x5728;&#x4E2D;&#x7684;Site Footer&#x4E0B;&#x9762;&#x65B9;&#x6846;&#x8F38;&#x5165;&#x4EE5;&#x4E0B;&#x7A0B;&#x5F0F;&#x78BC;:</p>
<pre><code class="language-handlebars">&lt;!-- code block --&gt;
&lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/prism/1.28.0/components/prism-core.min.js&quot; integrity=&quot;sha512-9khQRAUBYEJDCDVP2yw3LRUQvjJ0Pjx0EShmaQjcHa6AXiOv6qHQu9lCAIR8O+/D8FtaCoJ2c0Tf9Xo7hYH01Q==&quot; crossorigin=&quot;anonymous&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/prism/1.28.0/plugins/autoloader/prism-autoloader.min.js&quot; integrity=&quot;sha512-fTl/qcO1VgvKtOMApX2PdZzkziyr2stM65GYPLGuYMnuMm1z2JLJG6XVU7C/mR+E7xBUqCivykuhlzfqxXBXbg==&quot; crossorigin=&quot;anonymous&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;/script&gt;
</code></pre>
<h2 id="table-of-contents">T<strong>able of Contents</strong></h2>
<p>&#x5728;&#x95B1;&#x8B80;&#x9577;&#x6587;&#x7AE0;&#x6216;&#x662F;&#x60F3;&#x8981;&#x67E5;&#x95B1;&#x6587;&#x7AE0;&#x7279;&#x5B9A;&#x5167;&#x5BB9;&#x7684;&#x6642;&#x5019;&#xFF0C;&#x5982;&#x679C;&#x6709;&#x500B;&#x76EE;&#x9304;&#x7684;&#x8A71;&#x53EF;&#x4EE5;&#x5E6B;&#x52A9;&#x4F60;&#x5FEB;&#x901F;&#x60F3;&#x8981;&#x770B;&#x5230;&#x7684;&#x5167;&#x5BB9;&#x3002;Tocbot&#x662F;&#x4E00;&#x500B;JavaScript&#x7684;&#x5957;&#x4EF6;&#xFF0C;&#x6703;&#x53BB;&#x6383;&#x63CF;&#x7DB2;&#x9801;&#x7684;&#x5167;&#x5BB9;&#x81EA;&#x52D5;&#x751F;&#x6210;&#x76EE;&#x9304;&#x3001;&#x5275;&#x5EFA;&#x6307;&#x5411;&#x90A3;&#x4E9B;&#x6A19;&#x984C;&#x7684;&#x93C8;&#x7D50;&#x3001;&#x5C55;&#x793A;&#x5B83;&#x5011;&#x5728;&#x9801;&#x9762;&#x4E0A;&#x7684;&#x4F4D;&#x7F6E;&#xFF0C;&#x4E26;&#x6839;&#x64DA;&#x9801;&#x9762;&#x7684;&#x6A19;&#x984C;&#x5C64;&#x6B21;&#x5206;&#x5C64;&#x7D44;&#x6210;&#x76EE;&#x9304;&#xFF0C;&#x9019;&#x589E;&#x52A0;&#x4E86;&#x7528;&#x6236;&#x5C0D;&#x7DB2;&#x9801;&#x5167;&#x5BB9;&#x7684;&#x5C0E;&#x822A;&#x80FD;&#x529B;&#x3002;</p>
<p>&#x53E6;&#x5916;Tocbot&#x5141;&#x8A31;&#x958B;&#x767C;&#x8005;&#x9032;&#x884C;&#x591A;&#x7A2E;&#x81EA;&#x5B9A;&#x7FA9;&#x8A2D;&#x7F6E;&#xFF0C;&#x5305;&#x62EC;&#x76EE;&#x9304;&#x6A23;&#x5F0F;&#x3001;&#x6DF1;&#x5EA6;&#x3001;&#x4F4D;&#x7F6E;&#x7B49;&#xFF0C;&#x4E5F;&#x80FD;&#x5920;&#x5728;&#x4E0D;&#x540C;&#x7684;&#x8A2D;&#x5099;&#x4E0A;&#x63D0;&#x4F9B;&#x826F;&#x597D;&#x7684;&#x4F7F;&#x7528;&#x9AD4;&#x9A57;&#xFF0C;&#x5305;&#x62EC;&#x684C;&#x9762;&#x548C;&#x79FB;&#x52D5;&#x8A2D;&#x5099;&#x3002;&#x76EE;&#x524D;&#x7684;Ghost&#x90E8;&#x843D;&#x683C;Casper&#x4E3B;&#x984C;&#x9700;&#x8981;&#x4FEE;&#x6539;<code>default.hbs</code>&#x548C;<code>post.hbs</code>&#x5169;&#x500B;&#x500B;&#x500B;&#x6587;&#x4EF6;&#x3002;</p>
<h3 id="%E7%B7%A8%E8%BC%AFdefaulthbs">&#x7DE8;&#x8F2F;default.hbs</h3>
<p>&#x5728;&#x524D;&#x9762;<code>head</code>&#x6A19;&#x7C64;&#x4E2D;<code>{{ghost_head}}</code>&#x6DFB;&#x52A0;Tocbot&#x7684;css&#x6A23;&#x5F0F;&#xFF0C;&#x9019;&#x88E1;&#x4F7F;&#x7528;&#x7684;&#x662F;4.18.2&#x7248;&#x672C;&#xFF0C;&#x5982;&#x679C;&#x5F8C;&#x7E8C;&#x6709;&#x9700;&#x8981;&#x5347;&#x7D1A;&#x518D;&#x66F4;&#x6539;&#x9019;&#x88E1;&#x7684;&#x7248;&#x672C;&#x865F;&#xFF1A;</p>
<pre><code class="language-handlebars">&lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdnjs.cloudflare.com/ajax/libs/tocbot/4.18.2/tocbot.css&quot;&gt;</code></pre>
<p>&#x5982;&#x679C;&#x76F4;&#x63A5;&#x4F7F;&#x7528;<a href="https://ghost.org/tutorials/adding-comments/?ref=ghost.augustushsu.com">Ghost&#x5B98;&#x65B9;&#x6559;&#x5B78;</a>&#x7684;&#x65B9;&#x5F0F;&#x6703;&#x767C;&#x73FE;&#x751F;&#x6210;&#x76EE;&#x9304;&#x524D;&#x9762;&#x7684;&#x6A19;&#x865F;&#x662F;&#x7528;&#x82F1;&#x6587;&#x7684;abc&#xFF0C;&#x6240;&#x4EE5;&#x91DD;&#x5C0D;<code>.gh-content ol ol ol li</code>&#x548C;<code>gh-content ol ol ol li</code>&#x589E;&#x52A0;&#x4E86;<code>list-style-type: decimal</code>&#xFF0C;&#x53EF;&#x4EE5;&#x8B93;&#x751F;&#x6210;&#x7684;&#x6A19;&#x865F;&#x8F49;&#x63DB;&#x70BA;&#x6578;&#x5B57;&#xFF1A;</p>
<pre><code class="language-handlebars">&lt;style&gt;
.gh-content {
    position: relative;
}

/* Start overwrite assets/built/screen.css */
.gh-content ol ol ol li{
    list-style-type: decimal;
}

.gh-content ol ol li{
    list-style-type: decimal;
}
/* End overwrite assets/built/screen.css */

.gh-toc &gt; .toc-list {
    position: relative;
}

.toc-list {
    overflow: hidden;
    list-style: none;
    padding-left: 20px;
}

@media (min-width: 1300px) {
    .gh-sidebar {
        position: absolute; 
        top: 0;
        bottom: 0;
        margin-top: 4vmin;
        grid-column: wide-start / main-start; /* Place the TOC to the left of the content */
    }

    .gh-toc {
        position: sticky; /* On larger screens, TOC will stay in the same spot on the page */
        top: 4vmin;
    }
}

.gh-toc .is-active-link::before {
    background-color: var(--ghost-accent-color); /* Defines TOC   accent color based on Accent color set in Ghost Admin */
} 
&lt;/style&gt;</code></pre>
<p>&#x63A5;&#x4E0B;&#x4F86;&#x7684;&#x7A0B;&#x5E8F;&#x5728;<code>{{ghost_foot}}</code>&#x6DFB;&#x52A0; Tocbot &#x7684; JS &#x4EE3;&#x78BC;&#x4E4B;&#x524D;&#xFF0C;&#x7248;&#x672C;&#x540C;&#x6A23;&#x4F7F;&#x7528; 4.18.2&#xFF1A;</p>
<pre><code class="language-handlebars">{{!-- Tocbot script --}}
&lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/tocbot/4.18.2/tocbot.min.js&quot;&gt;&lt;/script&gt;</code></pre>
<p>&#x5728;&#x6700;&#x8FD1;&#x4E00;&#x6BB5;&#x6642;&#x9593;<code>script</code>&#x4E4B;&#x5F8C;&#x65B0;&#x589E;&#x4E86;&#x4E0B;&#x4E00;&#x500B;&#x7528;&#x65BC;&#x521D;&#x59CB;&#x5316; Tocbot &#x7684;&#x65B9;&#x7A0B;&#x5F0F;&#xFF0C;&#x5176;&#x4E2D;<code>.gh-toc</code>&#x548C;<code>gh-content</code>&#x7528;&#x65BC;&#x5339;&#x914D; Casper &#x7684; CSS &#x985E;&#x5225;&#xFF1A;</p>
<pre><code class="language-handlebars">{{! Initialize Tocbot after you load the script }}
&lt;script&gt;
    tocbot.init({
        // Where to render the table of contents.
        tocSelector: &apos;.gh-toc&apos;,
        // Where to grab the headings to build the table of contents.
        contentSelector: &apos;.gh-content&apos;,
        // Which headings to grab inside of the contentSelector element.
        headingSelector: &apos;h1, h2, h3, h4&apos;,
        // Ensure correct positioning
        hasInnerContainers: true,
    });
&lt;/script&gt;</code></pre>
<h3 id="%E7%B7%A8%E8%BC%AFposthbs">&#x7DE8;&#x8F2F;post.hbs</h3>
<p>&#x5728;<code>post.hbs</code>&#x4E2D;<code>{{content}}</code>&#x524D;&#x65B0;&#x589E;TOC&#x7684;<code>div</code>&#x6A19;&#x7C64;&#xFF1A;</p>
<pre><code class="language-handlebars">&lt;section class=&quot;gh-content gh-canvas&quot;&gt;
    {{! The TOC will be inserted here }}
    &lt;aside class=&quot;gh-sidebar&quot;&gt;&lt;div class=&quot;gh-toc&quot;&gt;&lt;/div&gt;&lt;/aside&gt;
    {{content}}
&lt;/section&gt;</code></pre>
<h2 id="%E5%9B%9E%E5%88%B0%E9%A0%82%E9%83%A8%E6%8C%89%E9%88%95%E3%80%81%E9%A1%AF%E7%A4%BA%E9%96%B1%E8%AE%80%E9%80%B2%E5%BA%A6"><strong>&#x56DE;&#x5230;&#x9802;&#x90E8;&#x6309;&#x9215;&#x3001;&#x986F;&#x793A;&#x95B1;&#x8B80;&#x9032;&#x5EA6;</strong></h2>
<p>&#x548C;&#x524D;&#x9762;&#x7684;TOC&#x76F8;&#x540C;&#xFF0C;&#x5728;<code>default.hbs</code>&#x7684;<code>{{ghost_head}}</code>&#x524D;&#x52A0;&#x5165;&#x4EE5;&#x4E0B;&#x9019;&#x6BB5;&#xFF0C;&#x9019;&#x500B;&#x6EFE;&#x52D5;&#x5230;&#x9802;&#x90E8;&#x7684;&#x6309;&#x9215;&#x662F;&#x53C3;&#x8003;<a href="https://brightthemes.com/blog/ghost-scroll-top?ref=ghost.augustushsu.com">&#x9019;&#x7BC7;&#x6587;&#x7AE0;</a>&#xFF0C;&#x5176;&#x4E2D;&#x6709;&#x91DD;&#x5C0D;&#x4F7F;&#x7528;&#x7684;&#x4E3B;&#x984C;&#x505A;&#x4E00;&#x4E9B;&#x4FEE;&#x6539;&#xFF0C;&#x50CF;&#x662F;&#x628A;&#x4F4D;&#x7F6E;&#x79FB;&#x5230;&#x53F3;&#x4E0A;&#x89D2;&#x3001;&#x984F;&#x8272;&#x65B9;&#x9762;&#x6539;&#x52D5;:</p>
<pre><code class="language-handlebars">&lt;style&gt;
.scroll-top {
    position: fixed;
    z-index: 50;
    padding: 0;
    right: 60px;
    top: 100px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(15px);    
    height: 46px;
    width: 46px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all .4s ease;
    border: none;
    color: #ccc;
    background-color: #fff;
}

.scroll-top.is-active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.scroll-top .icon-tabler-arrow-up {
    position: absolute;
    stroke-width: 2px;
    stroke: #333;
}

.scroll-top svg path { 
    fill: none; 
}

.scroll-top svg.progress-circle path {
    stroke: color-mix(in srgb, var(--ghost-accent-color), #000 50%);
    stroke-width: 4;
    transition: all .4s ease;
}

.scroll-top:hover {
    color: red;
}

.scroll-top:hover .progress-circle path, .scroll-top:hover .icon-tabler-arrow-up {
    stroke: var(--ghost-accent-color);
} 

/* Dark Mode */
html.dark-mode .scroll-top {
    color: #fff;
    background-color: var(--ghost-accent-color);
}
html.dark-mode .scroll-top .icon-tabler-arrow-up {
    position: absolute;
    stroke-width: 2px;
    stroke: #fff;
}
html.dark-mode .scroll-top svg.progress-circle path {
    stroke: color-mix(in srgb, var(--ghost-accent-color), #fff 50%);
    stroke-width: 4;
    transition: all .4s ease;
}
html.dark-mode .scroll-top:hover .progress-circle path {
    stroke: #fff;
}
html.dark-mode .scroll-top:hover .icon-tabler-arrow-up {
    stroke: #fff;
} 
@media (max-width: 991px) {
    .scroll-top {
        right: calc(50% - 23px);
        top: 35px;
    }
}
&lt;/style&gt;</code></pre>
<p>&#x4E00;&#x6A23;&#x5728;<code>default.hbs</code>&#x4E0A;&#xFF0C;&#x5C07;&#x4E0B;&#x9762;&#x7A0B;&#x5F0F;&#x78BC;&#x65B0;&#x589E;&#x5728;<code>{{ghost_foot}}</code>&#x524D;:</p>
<pre><code class="language-handlebars">&lt;!-- Scroll to Top --&gt;
&lt;script&gt;
    const scrollTopBtn = document.querySelector(&apos;.js-scroll-top&apos;);
    if (scrollTopBtn) {
        scrollTopBtn.onclick = () =&gt; {
            window.scrollTo({top: 0, behavior: &apos;smooth&apos;});
        }
        
        const progressPath = document.querySelector(&apos;.scroll-top path&apos;);
        const pathLength = progressPath.getTotalLength();
        progressPath.style.transition = progressPath.style.WebkitTransition = &apos;none&apos;;
        progressPath.style.strokeDasharray = `${pathLength} ${pathLength}`;
        progressPath.style.strokeDashoffset = pathLength;
        progressPath.getBoundingClientRect();
        progressPath.style.transition = progressPath.style.WebkitTransition = &apos;stroke-dashoffset 10ms linear&apos;;		
        const updateProgress = function() {
            const scroll = window.scrollY || window.scrollTopBtn || document.documentElement.scrollTopBtn;

            const docHeight = Math.max(
            document.body.scrollHeight, document.documentElement.scrollHeight,
            document.body.offsetHeight, document.documentElement.offsetHeight,
            document.body.clientHeight, document.documentElement.clientHeight
            );

            const windowHeight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);

            const height = docHeight - windowHeight;
            var progress = pathLength - (scroll * pathLength / height);
            progressPath.style.strokeDashoffset = progress;
        }

        updateProgress();
        const offset = 100;

        window.addEventListener(&apos;scroll&apos;, function(event) {
            updateProgress();

            //Scroll back to top
            const scrollPos = window.scrollY || window.scrollTopBtn || document.getElementsByTagName(&apos;html&apos;)[0].scrollTopBtn;
            scrollPos &gt; offset ? scrollTopBtn.classList.add(&apos;is-active&apos;) : scrollTopBtn.classList.remove(&apos;is-active&apos;);

        }, false);
    }
&lt;/script&gt;</code></pre>
<p></p>
<p></p>]]></content:encoded></item><item><title><![CDATA[Python Note 03]]></title><description><![CDATA[介紹pytest的fixture、conftest功能，透過pytest的一些插件來產生報表。]]></description><link>https://ghost.augustushsu.com/python-note-03/</link><guid isPermaLink="false">65017d365677df0593b384c1</guid><category><![CDATA[Python-Note]]></category><dc:creator><![CDATA[AugustusHsu]]></dc:creator><pubDate>Sun, 22 Oct 2023 12:00:51 GMT</pubDate><media:content url="https://ghost.augustushsu.com/content/images/2023/10/python-note03-cover.png" medium="image"/><content:encoded><![CDATA[<h1 id="%E5%9F%BA%E6%96%BCpytest%E6%A1%86%E6%9E%B6%E7%9A%84%E8%87%AA%E5%8B%95%E5%8C%96%E6%B8%AC%E8%A9%A6-%E4%B8%8B">&#x57FA;&#x65BC;Pytest&#x6846;&#x67B6;&#x7684;&#x81EA;&#x52D5;&#x5316;&#x6E2C;&#x8A66; (&#x4E0B;)</h1>
<img src="https://ghost.augustushsu.com/content/images/2023/10/python-note03-cover.png" alt="Python Note 03"><p>&#x524D;&#x9762;&#x4ECB;&#x7D39;&#x4E86;&#x76F4;&#x63A5;&#x4F7F;&#x7528;&#x6E2C;&#x8A66;&#x51FD;&#x6578;&#x3001;&#x7528;class&#x5305;&#x88DD;&#x6E2C;&#x8A66;&#x3001;<code>setup</code>&#x548C;<code>teardown</code>&#x3001;&#x53C3;&#x6578;&#x5316;&#x6E2C;&#x8A66;&#x6848;&#x4F8B;&#x3001;&#x9A57;&#x8B49;&#x9810;&#x671F;&#x7684;&#x932F;&#x8AA4;&#x548C;&#x8DF3;&#x904E;&#x932F;&#x8AA4;&#xFF0C;&#x9019;&#x4E9B;&#x662F;pytest&#x57FA;&#x672C;&#x7684;&#x6E2C;&#x8A66;&#x65B9;&#x6CD5;&#xFF0C;&#x63A5;&#x4E0B;&#x4F86;&#x6703;&#x900F;&#x904E;pytest&#x7684;fixture&#x3001;conftest&#x4F86;&#x6574;&#x5408;&#x9019;&#x4E9B;&#x529F;&#x80FD;&#xFF0C;&#x9084;&#x6709;&#x900F;&#x904E;pytest&#x7684;&#x4E00;&#x4E9B;&#x63D2;&#x4EF6;&#x4F86;&#x7522;&#x751F;&#x5831;&#x8868;&#xFF0C;&#x8B93;pytest&#x7684;&#x529F;&#x80FD;&#x8B8A;&#x5F97;&#x66F4;&#x52A0;&#x5F37;&#x5927;&#x548C;&#x9748;&#x6D3B;&#x3002;</p>
<h2 id="%E9%80%B2%E9%9A%8E%E5%8A%9F%E8%83%BD">&#x9032;&#x968E;&#x529F;&#x80FD;</h2>
<p>&#x63A5;&#x4E0B;&#x4F86;&#x4ECB;&#x7D39;&#x7684;&#x662F; pytest &#x7684;&#x9032;&#x968E;&#x529F;&#x80FD;&#xFF0C;&#x5206;&#x5225;&#x6709;<code>fixture</code>&#x3001;<code>conftest</code>&#x548C;&#x7522;&#x751F;&#x5831;&#x8868;&#x7684;&#x65B9;&#x6CD5;&#x3002;</p>
<h3 id="fixture">fixture</h3>
<p>fixtures&#x662F;pytest&#x4E2D;&#x7684;&#x4E00;&#x500B;&#x95DC;&#x9375;&#x6982;&#x5FF5;&#xFF0C;&#x4ED6;&#x6709;&#x524D;&#x9762;&#x4ECB;&#x7D39;&#x7684;<code>setup</code>&#x8DDF;<code>teardown</code>&#x4E00;&#x6A23;&#x7684;&#x529F;&#x80FD;&#xFF0C;&#x53EF;&#x4EE5;&#x5E6B;&#x52A9;&#x5EFA;&#x69CB;&#x6E2C;&#x8A66;&#x6240;&#x9700;&#x7684;&#x74B0;&#x5883;&#xFF0C;&#x4E26;&#x5728;&#x6E2C;&#x8A66;&#x51FD;&#x6578;&#x4E2D;&#x91CD;&#x8907;&#x4F7F;&#x7528;:</p>
<pre><code class="language-python">import pytest


@pytest.fixture
def setup_teardown_example():
    # &#x5728;&#x6E2C;&#x8A66;&#x4E4B;&#x524D;&#x57F7;&#x884C;&#x7684;&#x4EE3;&#x78BC;
    test_data = &quot;&#x5728;&#x8CC7;&#x6599;&#x5EAB;&#x4E2D;&#x6E96;&#x5099;&#x6E2C;&#x8A66;&#x8CC7;&#x6599;&quot;
    yield test_data
    # &#x5728;&#x6E2C;&#x8A66;&#x4E4B;&#x5F8C;&#x57F7;&#x884C;&#x7684;&#x4EE3;&#x78BC;
    print(&quot;&#x6E05;&#x7406;&#x6E2C;&#x8A66;&#x8CC7;&#x6599;&quot;)


def test_using_fixture(setup_teardown_example):
    test_data = setup_teardown_example
    # &#x4F7F;&#x7528; fixture
    assert something == expected_result
</code></pre>
<p>fixture&#x53EF;&#x4F7F;&#x7528;&#x7684;&#x53C3;&#x6578;&#x6709;&#x4E0B;&#x5217;&#x4E09;&#x7A2E;:</p>
<ul><li><code>scope</code>&#xFF1A;&#x8868;&#x793A;&#x4F5C;&#x7528;&#x57DF;&#xFF0C;&#x9810;&#x8A2D;&#x70BA;<code>function</code>&#x3002;</li><li><code>name</code>&#xFF1A;&#x7528;&#x4F86;&#x8A2D;&#x5B9A;fixture&#x7684;&#x5225;&#x540D;&#xFF0C;&#x9810;&#x8A2D;&#x70BA;&#x51FD;&#x5F0F;&#x540D;&#x7A31;</li><li><code>autouse</code>&#xFF1A;&#x9810;&#x8A2D;&#x70BA;False&#xFF0C;&#x82E5;&#x70BA;True&#xFF0C;&#x5247;&#x6703;&#x81EA;&#x52D5;&#x9032;&#x884C;&#x4F7F;&#x7528; (&#x6839;&#x64DA;scope&#x4F5C;&#x7528;&#x57DF;&#x800C;&#x5B9A;)</li></ul>
<p>&#x5176;&#x4E2D;fixture&#x7684;<code>scope</code>&#x4F5C;&#x7528;&#x57DF;&#x8DDF;<code>setup</code>&#x8DDF;<code>teardown</code>&#x6709;&#x7565;&#x5FAE;&#x4E0D;&#x540C;&#xFF0C;&#x7E3D;&#x5171;&#x6709;&#x56DB;&#x7A2E;&#xFF0C;&#x5206;&#x5225;&#x70BA;:</p>
<ol><li><code>function</code> : &#x9810;&#x8A2D;&#x7684;&#x9078;&#x9805;&#xFF0C;&#x5728;&#x6BCF;&#x500B;&#x6E2C;&#x8A66;&#x51FD;&#x6578;&#x904B;&#x884C;&#x4E4B;&#x524D;&#x548C;&#x4E4B;&#x5F8C;&#x57F7;&#x884C;&#xFF0C;&#x5404;&#x6E2C;&#x8A66;&#x51FD;&#x6578;&#x90FD;&#x5C07;&#x7372;&#x5F97;&#x4E00;&#x500B;&#x65B0;&#x7684;&#x3001;&#x7368;&#x7ACB;&#x7684;fixture&#x5BE6;&#x4F8B;&#xFF0C;&#x4E0D;&#x6703;&#x5171;&#x4EAB;&#x6578;&#x64DA;&#x3002;</li><li><code>class</code> : Fixture&#x5C07;&#x5728;&#x6BCF;&#x500B;&#x6E2C;&#x8A66;&#x985E; (&#x4F7F;&#x7528;<strong><code>@pytest.mark.usefixtures</code></strong>&#x88DD;&#x98FE;&#x5668;) &#x4E2D;&#x7684;&#x6E2C;&#x8A66;&#x51FD;&#x6578;&#x4E4B;&#x524D;&#x548C;&#x4E4B;&#x5F8C;&#x57F7;&#x884C;&#xFF0C;&#x5728;&#x591A;&#x500B;&#x6E2C;&#x8A66;&#x51FD;&#x6578;&#x4E4B;&#x9593;&#x5171;&#x4EAB;&#x76F8;&#x540C;&#x7684;fixture&#x6578;&#x64DA;&#x975E;&#x5E38;&#x6709;&#x7528;&#x3002;</li><li><code>module</code> : &#x5728;&#x6574;&#x500B;&#x6E2C;&#x8A66;&#x6A21;&#x584A; (&#x6E2C;&#x8A66;&#x6587;&#x4EF6;) &#x4E2D;&#x7684;&#x6E2C;&#x8A66;&#x51FD;&#x6578;&#x4E4B;&#x9593;&#x57F7;&#x884C;&#xFF0C;&#x5C0D;&#x65BC;&#x5728;&#x6A21;&#x584A;&#x7D1A;&#x5225;&#x5171;&#x4EAB;&#x6578;&#x64DA;&#x975E;&#x5E38;&#x6709;&#x7528;&#x3002;</li><li><code>session</code> : &#x6574;&#x500B;pytest&#x6703;&#x8A71; (&#x6240;&#x6709;&#x6E2C;&#x8A66;&#x6A21;&#x584A;) &#x4E2D;&#x7684;&#x6E2C;&#x8A66;&#x51FD;&#x6578;&#x4E4B;&#x524D;&#x548C;&#x4E4B;&#x5F8C;&#x57F7;&#x884C;&#xFF0C;&#x5141;&#x8A31;&#x5728;&#x591A;&#x500B;&#x6A21;&#x584A;&#x4E4B;&#x9593;&#x5171;&#x4EAB;<strong>&#x6301;&#x4E45;&#x6027;&#x6578;&#x64DA;</strong>&#x3002;</li></ol>
<p>&#x6BD4;&#x8F03;&#x7279;&#x5225;&#x7684;&#x662F;fixture&#x5728;class&#x4E0A;&#x7684;&#x61C9;&#x7528;&#xFF0C;&#x4EE5;&#x4E0B;&#x662F;&#x4F7F;&#x7528;<strong><code>@pytest.mark.usefixtures</code></strong>&#x7684;&#x7BC4;&#x4F8B;&#xFF0C;fixture&#x6703;&#x5728;&#x6E2C;&#x8A66;class&#x7684;&#x6240;&#x6709;&#x65B9;&#x6CD5;&#x4E4B;&#x524D;&#x904B;&#x884C;&#x4E00;&#x6B21;&#xFF0C;&#x6703;&#x5728;&#x6574;&#x500B;class&#x4E2D;&#x5171;&#x4EAB;&#x6578;&#x64DA;&#xFF0C;&#x7136;&#x5F8C;&#x5728;&#x6240;&#x6709;&#x6E2C;&#x8A66;&#x65B9;&#x6CD5;&#x57F7;&#x884C;&#x5B8C;&#x6210;&#x5F8C;&#x9032;&#x884C;&#x6E05;&#x7406;:</p>
<pre><code class="language-python">import pytest

@pytest.fixture(scope=&quot;class&quot;)
def class_fixture():
    # &#x5728;&#x6E2C;&#x8A66;&#x985E;&#x5225;&#x4E2D;&#x7684;&#x6E2C;&#x8A66;&#x65B9;&#x6CD5;&#x4E4B;&#x524D;&#x548C;&#x4E4B;&#x5F8C;&#x57F7;&#x884C;&#x4E00;&#x6B21;&#x7684;fixture
    print(&quot;Class fixture setup&quot;)
    yield
    print(&quot;Class fixture teardown&quot;)

@pytest.mark.usefixtures(&quot;class_fixture&quot;)
class TestClassWithFixture:

    def test_method1(self):
        print(&quot;Test method 1&quot;)

    def test_method2(self):
        print(&quot;Test method 2&quot;)</code></pre>
<p>&#x4EE5;&#x4E0B;&#x5C55;&#x793A;&#x4E86;fixture&#x5728;&#x5404;&#x500B;&#x5C64;&#x7D1A;&#x4F7F;&#x7528;&#x7684;&#x7BC4;&#x4F8B;&#xFF0C;&#x5728;&#x9019;&#x500B;&#x7BC4;&#x4F8B;&#x4E2D;&#x5C55;&#x793A;&#x4E86;fixture&#x5728;session&#x5275;&#x5EFA;&#x4E86;&#x8207;&#x8CC7;&#x6599;&#x5EAB;&#x7684;&#x9023;&#x7D50;&#xFF1B;&#x5728;module&#x5C64;&#x7D1A;&#x4E0A;&#x7684;&#x6307;&#x5B9A;&#x4E86;&#x6E2C;&#x8A66;&#x7528;&#x7684;collection&#x4E26;&#x63D2;&#x5165;&#x6578;&#x64DA;&#x7528;&#x65BC;&#x6E2C;&#x8A66;&#xFF1B;&#x5728;class&#x5C64;&#x7D1A;&#x4E0A;&#x65B0;&#x589E;&#x4E86;&#x6E2C;&#x8A66;&#x8CC7;&#x6599;&#x8B93;&#x5F8C;&#x7E8C;&#x7684;class&#x7D1A;&#x5225;&#x7684;&#x6E2C;&#x8A66;&#x65B9;&#x6CD5;&#x53EF;&#x4EE5;&#x9032;&#x884C;&#x6E2C;&#x8A66;:</p>
<pre><code class="language-python">import pytest
from pymongo import MongoClient


# &#x5B9A;&#x7FA9;&#x4E00;&#x500B;&#x5177;&#x6709;session&#x7D1A;&#x5225;MongoDB client&#x7684;fixture
@pytest.fixture(scope=&quot;session&quot;)
def mongodb_connection():
    # &#x9023;&#x63A5;&#x5230;MongoDB&#x7684;Client
    client = MongoClient(&apos;localhost&apos;, 27017)
    # &#x4F7F;&#x7528;&#x6E2C;&#x8A66;&#x7528;&#x7684;&#x8CC7;&#x6599;&#x5EAB;
    db = client[&apos;mytestdb&apos;]
    yield db
    # &#x6E05;&#x7406;&#x6E2C;&#x8A66;&#x7528;&#x8CC7;&#x6599;&#x5EAB;
    client.drop_database(&apos;mytestdb&apos;)


# &#x5B9A;&#x7FA9;&#x4E00;&#x500B;&#x5177;&#x6709;module&#x7D1A;&#x5225;&#x7684;&#x8CC7;&#x6599;&#x5EAB;&#x9023;&#x63A5;fixture&#xFF0C;&#x7528;&#x65BC;&#x63D2;&#x5165;Document
@pytest.fixture(scope=&quot;module&quot;)
def setup_mongodb_data(mongodb_connection):
    # &#x4F7F;&#x7528;&#x6E2C;&#x8A66;&#x96C6;&#x5408;&#x540D;&#x7A31;&#x5BEB;&#x5165;&#x6578;&#x64DA;
    collection = mongodb_connection[&apos;mycollection&apos;]
    data = [
        {&quot;_id&quot;: 1, &quot;name&quot;: &quot;user1&quot;},
        {&quot;_id&quot;: 2, &quot;name&quot;: &quot;user2&quot;},
    ]
    collection.insert_many(data)
    yield
    collection.delete_many({})


# &#x5B9A;&#x7FA9;&#x4E00;&#x500B;class&#x7D1A;&#x5225;&#x7684;fixture
@pytest.fixture(scope=&quot;class&quot;)
def class_fixture(mongodb_connection, setup_mongodb_data):
    # &#x5728;&#x6E2C;&#x8A66;&#x7684;class&#x4E2D;&#x6240;&#x6709;&#x6E2C;&#x8A66;&#x65B9;&#x6CD5;&#x4E4B;&#x524D;&#x548C;&#x4E4B;&#x5F8C;&#x904B;&#x884C;&#x4E00;&#x6B21;&#x7684;fixture&#x8A2D;&#x7F6E;
    collection = mongodb_connection[&apos;mycollection&apos;]
    data = {&quot;_id&quot;: 3, &quot;name&quot;: &quot;user3&quot;}
    collection.insert_one(data)
    yield
    collection.delete_one({&quot;_id&quot;: 3})


# &#x5728;&#x6E2C;&#x8A66;&#x7684;class&#x4E2D;&#x4F7F;&#x7528;&#x524D;&#x9762;&#x8A2D;&#x5B9A;&#x7684;fixture&#x9032;&#x884C;&#x6E2C;&#x8A66;
@pytest.mark.usefixtures(&quot;class_fixture&quot;)
class TestMongoDBClass:

    def test_fetch_user_data(self, mongodb_connection):
        collection = mongodb_connection[&apos;mycollection&apos;]
        user = collection.find_one({&quot;_id&quot;: 1})
        assert user[&quot;name&quot;] == &apos;user1&apos;
  
    def test_another_test(self, mongodb_connection):
        collection = mongodb_connection[&apos;mycollection&apos;]
        user = collection.find_one({&quot;_id&quot;: 2})
        assert user[&quot;name&quot;] == &apos;user2&apos;
  
    def test_class_fixture(self, mongodb_connection):
        collection = mongodb_connection[&apos;mycollection&apos;]
        user = collection.find_one({&quot;_id&quot;: 3})
        assert user[&quot;name&quot;] == &apos;user3&apos;
</code></pre>
<h3 id="conftest">conftest</h3>
<p><code>conftest.py</code>&#x662F;pytest&#x4E2D;&#x4E00;&#x500B;&#x7279;&#x6B8A;&#x7684;&#x6A21;&#x584A;&#xFF0C;&#x5B83;&#x5141;&#x8A31;&#x5728;&#x4E0D;&#x540C;&#x7684;&#x6E2C;&#x8A66;&#x6587;&#x4EF6;&#x4E4B;&#x9593;&#x5171;&#x4EAB; fixture&#x3001;&#x81EA;&#x5B9A;&#x7FA9; hook &#x51FD;&#x6578;&#x548C;&#x914D;&#x7F6E;&#x9078;&#x9805;&#xFF0C;&#x7C21;&#x800C;&#x8A00;&#x4E4B;&#x5C31;&#x662F;&#x4E00;&#x500B;&#x53EF;&#x4EE5;&#x5B58;&#x653E;<strong>&#x7D93;&#x5E38;&#x88AB;&#x4F7F;&#x7528;&#x5230;</strong> fixture&#x7684;&#x5730;&#x65B9;&#x3002;</p>
<p>pytest&#x5728;&#x4E00;&#x958B;&#x59CB;&#x57F7;&#x884C;&#x6642;&#xFF0C;&#x5C31;&#x6703;&#x5148;&#x53BB;&#x6293;&#x662F;&#x5426;&#x6709;<code>conftest.py</code>&#x7684;&#x5B58;&#x5728;&#xFF0C;&#x800C;&#x5B58;&#x653E;&#x5728;<code>conftest.py</code>&#x7576;&#x4E2D;&#x7684;fixture<strong>&#x4E0D;&#x9700;&#x8981;&#x900F;&#x904E; import</strong>&#x5C31;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x9032;&#x884C;&#x4F7F;&#x7528;&#xFF0C;&#x5982;&#x679C;&#x6709;&#x67D0;&#x4E9B;fixture&#x6703;&#x88AB;&#x8A31;&#x591A;&#x500B;test module&#x4F7F;&#x7528;&#x7684;&#x8A71;&#xFF0C;&#x5C31;&#x53EF;&#x4EE5;&#x8A66;&#x8457;&#x5C07;&#x8A72;fixture&#x653E;&#x5230;<code>conftest.py</code>&#x7576;&#x4E2D;&#x3002;</p>
<p><code>conftest.py</code>&#x7684;&#x540D;&#x7A31;&#x548C;&#x4F4D;&#x7F6E;&#x662F;&#x56FA;&#x5B9A;&#x7684;&#xFF0C;&#x5FC5;&#x9808;&#x653E;&#x7F6E;&#x5728;&#x6E2C;&#x8A66;&#x9805;&#x76EE;&#x7684;&#x6839;&#x76EE;&#x9304;&#x6216;&#x5B50;&#x76EE;&#x9304;&#x4E0B;&#xFF0C;pytest&#x6703;&#x81EA;&#x52D5;&#x8B58;&#x5225;&#x4E26;&#x52A0;&#x8F09;&#x5B83;&#xFF0C;<code>conftest.py</code>&#x6240;&#x5B58;&#x5728;&#x7684;&#x7576;&#x524D;&#x76EE;&#x9304;&#x4EE5;&#x53CA;&#x5176;&#x6240;&#x6709;&#x5B50;&#x76EE;&#x8DEF;&#x4E2D;&#x7684;test case&#x90FD;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#xFF0C;&#x82E5;&#x65BC;&#x4E0D;&#x540C;&#x76EE;&#x9304;&#x5247;&#x9700;&#x8981;&#x53E6;&#x5916;&#x5BEB;&#x4E00;&#x500B;<code>conftest.py</code>&#x3002;</p>
<p>&#x4F7F;&#x7528;<code>conftest.py</code>&#x7684;&#x7684;&#x8CC7;&#x6599;&#x593E;&#x7D50;&#x69CB;&#x53EF;&#x4EE5;&#x5982;&#x4E0B;:</p>
<pre><code class="language-bash">&#x251C;&#x2500;src
&#x2502;  &#x251C;&#x2500;pkg1
&#x2502;  &#x2502;  &#x251C;&#x2500;__init__.py
&#x2502;  &#x2502;  &#x2514;&#x2500;module_a.py
&#x2502;  &#x2514;&#x2500;pkg2
&#x2502;     &#x251C;&#x2500;__init__.py
&#x2502;     &#x251C;&#x2500;module_a.py
&#x2502;     &#x2514;&#x2500;module_b.py
&#x251C;&#x2500;tests
&#x2502;  &#x251C;&#x2500;test_pkg1
&#x2502;  &#x2502;  &#x251C;&#x2500;__init__.py
&#x2502;  &#x2502;  &#x2514;&#x2500;test_case.py
&#x2502;  &#x251C;&#x2500;test_pkg2
&#x2502;  &#x2502;  &#x251C;&#x2500;__init__.py
&#x2502;  &#x2502;  &#x251C;&#x2500;test_case.py
&#x2502;  &#x2502;  &#x2514;&#x2500;conftest.py
&#x2502;  &#x251C;&#x2500;__init__.py
&#x2502;  &#x251C;&#x2500;conftest.py
&#x2502;  &#x2514;&#x2500;test_1.py
&#x2514;&#x2500;setup.py</code></pre>
<h3 id="%E7%94%A2%E7%94%9F%E5%A0%B1%E8%A1%A8">&#x7522;&#x751F;&#x5831;&#x8868;</h3>
<p>&#x524D;&#x9762;&#x4ECB;&#x7D39;&#x4E86;&#x8A31;&#x591A;&#x4F7F;&#x7528;pytest&#x7684;&#x65B9;&#x6CD5;&#xFF0C;&#x7576;&#x4F7F;&#x7528;pytest&#x57F7;&#x884C;&#x6E2C;&#x8A66;&#x6642;&#xFF0C;&#x7522;&#x751F;&#x5831;&#x8868;&#x4E5F;&#x662F;&#x975E;&#x5E38;&#x91CD;&#x8981;&#x7684;&#xFF0C;&#x9019;&#x662F;&#x56E0;&#x70BA;&#x6E2C;&#x8A66;&#x5831;&#x8868;&#x5177;&#x6709;&#x4EE5;&#x4E0B;&#x5E7E;&#x500B;&#x95DC;&#x9375;&#x7528;&#x9014;&#x548C;&#x512A;&#x52E2;:</p>
<ol><li><strong>&#x53EF;&#x8996;&#x5316;&#x6E2C;&#x8A66;&#x7D50;&#x679C;</strong>: &#x6E2C;&#x8A66;&#x5831;&#x8868;&#x53EF;&#x4EE5;&#x5C07;&#x6E2C;&#x8A66;&#x7D50;&#x679C;&#x4EE5;&#x6613;&#x65BC;&#x7406;&#x89E3;&#x7684;&#x65B9;&#x5F0F;&#x5448;&#x73FE;&#xFF0C;&#x901A;&#x5E38;&#x7528;&#x984F;&#x8272;&#x548C;&#x6A19;&#x7C64;&#x4F86;&#x5340;&#x5206;&#x901A;&#x904E;&#x7684;&#x6E2C;&#x8A66;&#x3001;&#x5931;&#x6557;&#x7684;&#x6E2C;&#x8A66;&#x548C;&#x932F;&#x8AA4;&#x7684;&#x6E2C;&#x8A66;&#xFF0C;&#x4F7F;&#x958B;&#x767C;&#x4EBA;&#x54E1;&#x80FD;&#x5920;&#x5FEB;&#x901F;&#x8B58;&#x5225;&#x548C;&#x5B9A;&#x4F4D;&#x554F;&#x984C;&#xFF0C;&#x4E26;&#x66F4;&#x5BB9;&#x6613;&#x7406;&#x89E3;&#x6E2C;&#x8A66;&#x7684;&#x904B;&#x884C;&#x60C5;&#x6CC1;&#x3002;</li><li><strong>&#x6B77;&#x53F2;&#x7D00;&#x9304;</strong>: &#x6E2C;&#x8A66;&#x5831;&#x8868;&#x901A;&#x5E38;&#x53EF;&#x4EE5;&#x4FDD;&#x5B58;&#x6B77;&#x53F2;&#x6E2C;&#x8A66;&#x904B;&#x884C;&#x7684;&#x7D50;&#x679C;&#xFF0C;&#x958B;&#x767C;&#x5718;&#x968A;&#x53EF;&#x4EE5;&#x8FFD;&#x8E64;&#x6E2C;&#x8A66;&#x904B;&#x884C;&#x7684;&#x8B8A;&#x5316;&#xFF0C;&#x5C0D;&#x65BC;&#x6AA2;&#x6E2C;&#x6E2C;&#x8A66;&#x8986;&#x84CB;&#x7387;&#x7684;&#x63D0;&#x9AD8;&#x6216;&#x6E2C;&#x8A66;&#x6027;&#x80FD;&#x7684;&#x6539;&#x9032;&#x975E;&#x5E38;&#x6709;&#x7528;&#x3002;</li><li><strong>&#x96C6;&#x6210;&#x5230;CI/CD&#x6D41;&#x7A0B;</strong>: &#x5728;CI/CD&#x6D41;&#x7A0B;&#x4E2D;&#xFF0C;&#x6E2C;&#x8A66;&#x5831;&#x8868;&#x53EF;&#x4EE5;&#x81EA;&#x52D5;&#x751F;&#x6210;&#x4E26;&#x4FDD;&#x5B58;&#xFF0C;&#x9019;&#x6A23;&#x5718;&#x968A;&#x53EF;&#x4EE5;&#x8F15;&#x9B06;&#x5730;&#x76E3;&#x8996;&#x61C9;&#x7528;&#x7A0B;&#x5E8F;&#x7684;&#x6E2C;&#x8A66;&#x72C0;&#x614B;&#xFF0C;&#x4E26;&#x78BA;&#x4FDD;&#x6BCF;&#x6B21;&#x90E8;&#x5C6C;&#x90FD;&#x662F;&#x7A69;&#x5B9A;&#x7684;&#x3002;&#x5982;&#x679C;&#x6E2C;&#x8A66;&#x5831;&#x544A;&#x986F;&#x793A;&#x554F;&#x984C;&#xFF0C;&#x5247;&#x53EF;&#x4EE5;&#x505C;&#x6B62;&#x90E8;&#x5C6C;&#xFF0C;&#x4EE5;&#x9632;&#x6B62;&#x6F5B;&#x5728;&#x7684;&#x932F;&#x8AA4;&#x9032;&#x5165;&#x751F;&#x7522;&#x74B0;&#x5883;&#x3002;</li><li><strong>&#x5206;&#x6790;&#x6E2C;&#x8A66;&#x7D50;&#x679C;</strong>: &#x6E2C;&#x8A66;&#x5831;&#x8868;&#x9084;&#x53EF;&#x4EE5;&#x63D0;&#x4F9B;&#x6E2C;&#x8A66;&#x904B;&#x884C;&#x6642;&#x9593;&#x3001;&#x6E2C;&#x8A66;&#x8986;&#x84CB;&#x7387;&#x3001;&#x6E2C;&#x8A66;&#x5931;&#x6557;&#x7684;&#x7D71;&#x8A08;&#x8A0A;&#x606F;&#x7B49;&#x7B49;&#xFF0C;&#x9019;&#x6709;&#x52A9;&#x65BC;&#x958B;&#x767C;&#x4EBA;&#x54E1;&#x9032;&#x884C;&#x6027;&#x80FD;&#x5206;&#x6790;&#x548C;&#x6E2C;&#x8A66;&#x8986;&#x84CB;&#x7387;&#x5206;&#x6790;&#x3002;</li></ol>
<p>&#x4EE5;&#x4E0B;&#x662F;pytest&#x5E38;&#x7528;&#x7522;&#x751F;&#x5831;&#x8868;&#x7684;&#x63D2;&#x4EF6;:</p>
<ul><li><code>pytest-json-report</code>: &#x7528;&#x65BC;&#x751F;&#x6210;JSON&#x683C;&#x5F0F;&#x7684;&#x6E2C;&#x8A66;&#x5831;&#x544A;&#x3002;<br>&#x4F7F;&#x7528;&#x65B9;&#x6CD5;: <code>pytest --json-report=path/to/report.json</code></li><li><code>pytest-cov</code>: &#x7528;&#x65BC;&#x6E2C;&#x8A66;&#x8986;&#x84CB;&#x7387;&#x5831;&#x544A;&#xFF0C;&#x53EF;&#x751F;&#x6210;HTML&#x4F9B;&#x6AA2;&#x8996;&#x3002;<br>&#x4F7F;&#x7528;&#x65B9;&#x6CD5;: <code>pytest --cov=&lt;your_package&gt; --cov-report=html</code></li><li><code>pytest-html</code>: &#x751F;&#x6210;&#x6F02;&#x4EAE;&#x7684;HTML&#x6E2C;&#x8A66;&#x5831;&#x544A; (4.0.2&#x6703;&#x6709;&#x554F;&#x984C;&#xFF0C;&#x76EE;&#x524D;&#x4F7F;&#x7528;3.2.0)&#x3002;<br>&#x4F7F;&#x7528;&#x65B9;&#x6CD5;: <code>pytest --html=report.html --self-contained-html</code></li><li><code>allure-pytest</code>: Allure&#x662F;&#x4E00;&#x500B;&#x958B;&#x6E90;&#x7684;&#x6E2C;&#x8A66;&#x5831;&#x544A;&#x6846;&#x67B6;&#xFF0C;&#x53EF;&#x7528;&#x65BC;&#x7D00;&#x9304;&#x3001;&#x5C55;&#x793A;&#x548C;&#x5206;&#x6790;&#x6E2C;&#x8A66;&#x7D50;&#x679C;&#xFF0C;&#x4E0B;&#x9762;&#x55AE;&#x7368;&#x4ECB;&#x7D39;&#x5982;&#x4F55;&#x4F7F;&#x7528;&#x9019;&#x500B;&#x5957;&#x4EF6;&#x3002;</li></ul>
<h3 id="allure">Allure</h3>
<p>&#x5B89;&#x88DD;Allure&#x9700;&#x8981;Java JDK&#x652F;&#x6301;&#xFF0C;&#x9700;&#x8981;&#x5230;<a href="https://www.oracle.com/java/technologies/downloads/?ref=ghost.augustushsu.com">&#x9019;&#x500B;&#x7DB2;&#x7AD9;</a>&#x5B89;&#x88DD;&#xFF0C;&#x63A5;&#x4E0B;&#x4F86;&#x76F4;&#x63A5;&#x5230;Allure&#x7684;<a href="https://github.com/allure-framework/allure2/releases?ref=ghost.augustushsu.com">Github&#x7DB2;&#x5740;</a>&#x4E0B;&#x8F09;&#x6700;&#x65B0;&#x7248;&#x672C;Allure&#x7684;zip&#x6A94;&#xFF0C;&#x5C07;allure-x.x.x/bin&#x653E;&#x5230;&#x7CFB;&#x7D71;&#x7684;PATH&#x4E2D;&#xFF0C;&#x53EF;&#x4EE5;&#x5728;&#x547D;&#x4EE4;&#x5217;&#x4E0A;&#x8F38;&#x5165;<code>allure --version</code>&#x6AA2;&#x67E5;&#x662F;&#x5426;&#x5B89;&#x88DD;&#x6210;&#x529F;&#x3002;</p>
<p>&#x63A5;&#x8457;&#x8981;&#x5B89;&#x88DD;allure&#x5728;pytest&#x7684;&#x5957;&#x4EF6;:</p>
<pre><code class="language-bash">poetry add allure-pytest</code></pre>
<p>&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x5728;&#x5C08;&#x6848;&#x5167;&#x57F7;&#x884C;&#x4EE5;&#x4E0B;&#x547D;&#x4EE4;&#xFF0C;&#x53EF;&#x4EE5;&#x5F97;&#x5230;&#x6E2C;&#x8A66;&#x7D50;&#x679C;&#x7684;&#x8CC7;&#x6599;:</p>
<pre><code class="language-bash">pytest --alluredir ./allure/data</code></pre>
<p>&#x53EF;&#x4EE5;&#x900F;&#x904E;&#x4EE5;&#x4E0B;&#x547D;&#x4EE4;&#x7522;&#x751F;&#x51FA;html&#x6A94;&#x6848;&#xFF0C;&#x53EF;&#x4EE5;&#x5C07;index.html&#x653E;&#x5230;&#x700F;&#x89BD;&#x5668;&#x4E2D;&#x67E5;&#x770B;&#x5831;&#x544A;:</p>
<pre><code class="language-bash">allure generate ./allure/data -o ./allure/report/ --clean</code></pre>
<p>&#x4E0D;&#x904E;&#x7528;&#x9019;&#x7A2E;&#x65B9;&#x5F0F;&#x53EF;&#x80FD;&#x6703;&#x9047;&#x5230;&#x7DB2;&#x9801;&#x6253;&#x958B;&#x4E86;&#xFF0C;&#x4F46;&#x8B80;&#x53D6;&#x4E0D;&#x5230;&#x6578;&#x64DA;&#x7684;&#x554F;&#x984C;&#xFF0C;&#x9019;&#x662F;&#x56E0;&#x70BA;CORS policy error&#x7684;&#x554F;&#x984C;&#xFF0C;&#x5982;&#x679C;&#x662F;&#x4F7F;&#x7528;Google Chrome&#xFF0C;&#x5728;&#x555F;&#x52D5;&#x6642;&#x9700;&#x8981;&#x52A0;&#x4E0A;&#x4EE5;&#x4E0B;&#x7684;&#x53C3;&#x6578;&#x4EE5;&#x907F;&#x514D;CORS policy error:</p>
<pre><code class="language-bash">--allow-file-access-from-files</code></pre>
<p>&#x6216;&#x662F;&#x53EF;&#x4EE5;&#x900F;&#x904E;&#x4EE5;&#x4E0B;&#x547D;&#x4EE4;&#x76F4;&#x63A5;&#x5EFA;&#x69CB;&#x4E00;&#x500B;&#x672C;&#x5730;Web&#x670D;&#x52D9;&#x5668;:</p>
<pre><code class="language-bash">allure serve ./allure/data</code></pre>
<p>Allure&#x9084;&#x6709;&#x8A31;&#x591A;&#x5176;&#x4ED6;&#x7684;&#x529F;&#x80FD;&#xFF0C;&#x5177;&#x9AD4;&#x53EF;&#x4EE5;&#x53C3;&#x8003;<a href="https://docs.qameta.io/allure-report/?ref=ghost.augustushsu.com">&#x5B98;&#x65B9;&#x6587;&#x6A94;</a>&#xFF0C;&#x5F8C;&#x7E8C;&#x6709;&#x6A5F;&#x6703;&#x4E5F;&#x53EF;&#x4EE5;&#x5C08;&#x9580;&#x70BA;Allure&#x5BEB;&#x4E00;&#x7BC7;&#x4ECB;&#x7D39;&#x6587;&#x3002;</p>
<h2 id="%E7%B5%90%E8%AB%96">&#x7D50;&#x8AD6;</h2>
<p>&#x6E2C;&#x8A66;&#x6846;&#x67B6;&#x5728;&#x8EDF;&#x4EF6;&#x958B;&#x767C;&#x904E;&#x7A0B;&#x4E2D;&#x626E;&#x6F14;&#x8457;&#x91CD;&#x8981;&#x7684;&#x89D2;&#x8272;&#xFF0C;&#x5B83;&#x4E0D;&#x50C5;&#x5E6B;&#x52A9;&#x6E2C;&#x8A66;&#x4EBA;&#x54E1;&#x9AD8;&#x6548;&#x5730;&#x57F7;&#x884C;&#x6E2C;&#x8A66;&#xFF0C;&#x9084;&#x6709;&#x52A9;&#x65BC;&#x958B;&#x767C;&#x5718;&#x968A;&#x78BA;&#x4FDD;&#x7522;&#x54C1;&#x8CEA;&#x91CF;&#x548C;&#x7A69;&#x5B9A;&#x6027;&#xFF0C;&#x6E2C;&#x8A66;&#x6846;&#x67B6;&#x662F;&#x4FDD;&#x8B49;&#x8EDF;&#x4EF6;&#x54C1;&#x8CEA;&#x7684;&#x4E0D;&#x53EF;&#x6216;&#x7F3A;&#x7684;&#x5DE5;&#x5177;&#x4E4B;&#x4E00;&#x3002;&#x9664;&#x932F;&#x548C;&#x6E2C;&#x8A66;&#x662F;&#x8EDF;&#x9AD4;&#x958B;&#x767C;&#x904E;&#x7A0B;&#x4E2D;&#x7684;&#x6B63;&#x5E38;&#x90E8;&#x5206;&#xFF0C;&#x4E0D;&#x8981;&#x5BB3;&#x6015;&#x82B1;&#x6642;&#x9593;&#x4F86;&#x9032;&#x884C;&#x9019;&#x4E9B;&#x5DE5;&#x4F5C;&#xFF0C;&#x6BCF;&#x6B21;&#x4FEE;&#x5FA9;&#x4E00;&#x500B;&#x932F;&#x8AA4;&#xFF0C;&#x7A0B;&#x5F0F;&#x5C07;&#x8B8A;&#x5F97;&#x66F4;&#x52A0;&#x7A69;&#x5B9A;&#x548C;&#x53EF;&#x9760;&#xFF0C;&#x6301;&#x7E8C;&#x5B78;&#x7FD2;&#x548C;&#x6539;&#x9032;&#x6E2C;&#x8A66;&#x548C;&#x9664;&#x932F;&#x6280;&#x5DE7;&#x4E5F;&#x662F;&#x63D0;&#x9AD8;&#x8EDF;&#x9AD4;&#x958B;&#x767C;&#x6548;&#x7387;&#x7684;&#x95DC;&#x9375;&#x3002;</p>]]></content:encoded></item><item><title><![CDATA[Python Note 02]]></title><description><![CDATA[Pytest是一個用於Python程式語言的測試框架，幫助管理測試的用例、執行測試、收集測試結果和生成測試報告等等。]]></description><link>https://ghost.augustushsu.com/python-note-02/</link><guid isPermaLink="false">65000b6e5677df0593b38172</guid><category><![CDATA[Python-Note]]></category><dc:creator><![CDATA[AugustusHsu]]></dc:creator><pubDate>Sun, 15 Oct 2023 12:00:28 GMT</pubDate><media:content url="https://ghost.augustushsu.com/content/images/2023/09/python-note02-cover.png" medium="image"/><content:encoded><![CDATA[<h1 id="%E5%9F%BA%E6%96%BCpytest%E6%A1%86%E6%9E%B6%E7%9A%84%E8%87%AA%E5%8B%95%E5%8C%96%E6%B8%AC%E8%A9%A6-%E4%B8%8A">&#x57FA;&#x65BC;Pytest&#x6846;&#x67B6;&#x7684;&#x81EA;&#x52D5;&#x5316;&#x6E2C;&#x8A66; (&#x4E0A;)</h1>
<img src="https://ghost.augustushsu.com/content/images/2023/09/python-note02-cover.png" alt="Python Note 02"><p>&#x5728;&#x5BEB;&#x7A0B;&#x5F0F;&#x7684;&#x6642;&#x5019;&#xFF0C;&#x6709;&#x6642;&#x6703;&#x4E0D;&#x592A;&#x78BA;&#x5B9A;&#x81EA;&#x5DF1;&#x7684;&#x7A0B;&#x5F0F;&#x662F;&#x4E0D;&#x662F;&#x6309;&#x7167;&#x81EA;&#x5DF1;&#x60F3;&#x7684;&#x4E00;&#x6A23;&#x5728;&#x57F7;&#x884C;&#xFF0C;&#x5F80;&#x5F80;&#x8981;&#x91DD;&#x5C0D;&#x500B;&#x5225;&#x6848;&#x4F8B;&#x9032;&#x884C;&#x624B;&#x52D5;&#x7684;&#x6E2C;&#x8A66;&#xFF0C;&#x800C;&#x4E14;&#x9084;&#x53EF;&#x80FD;&#x7121;&#x6CD5;&#x78BA;&#x5B9A;&#x6BCF;&#x4E00;&#x6B21;&#x6E2C;&#x8A66;&#x7684;&#x6771;&#x897F;&#x90FD;&#x662F;&#x76F8;&#x540C;&#x7684;&#xFF1B;&#x9664;&#x6B64;&#x4E4B;&#x5916;&#x7576;&#x9047;&#x5230;&#x4FEE;&#x6539;&#x67D0;&#x529F;&#x80FD;&#x7684;&#x6642;&#x5019;&#xFF0C;&#x6709;&#x6642;&#x6703;&#x83AB;&#x540D;&#x5730;&#x5F71;&#x97FF;&#x5230;&#x4E86;&#x53E6;&#x4E00;&#x500B;&#x529F;&#x80FD;&#xFF0C;&#x5C0E;&#x81F4;&#x7522;&#x51FA;&#x7684;&#x7D50;&#x679C;&#x4E0D;&#x7B26;&#x5408;&#x9810;&#x671F;&#x6216;&#x662F;&#x76F4;&#x63A5;&#x767C;&#x751F;&#x932F;&#x8AA4;&#xFF0C;&#x9019;&#x500B;&#x6642;&#x5019;&#x5C31;&#x9700;&#x8981;&#x4E00;&#x500B;&#x6E2C;&#x8A66;&#x6846;&#x67B6;&#x5C07;&#x6E2C;&#x8A66;&#x7684;&#x6D41;&#x7A0B;&#x898F;&#x7BC4;&#x5316;&#xFF0C;&#x5C07;&#x6BCF;&#x500B;&#x6E2C;&#x8A66;&#x5BEB;&#x6210;&#x4E00;&#x500B;&#x500B;&#x7684;&#x7528;&#x4F8B;&#x4F86;&#x9A57;&#x8B49;&#x5404;&#x500B;&#x529F;&#x80FD;&#x662F;&#x5426;&#x6B63;&#x78BA;&#x3002;</p>
<p>&#x6E2C;&#x8A66;&#x6846;&#x67B6;&#x6709;&#x5F88;&#x591A;&#x7A2E;&#xFF0C;&#x4E3B;&#x8981;&#x7684;&#x7528;&#x8655;&#x662F;&#x5E6B;&#x52A9;&#x7BA1;&#x7406;&#x6E2C;&#x8A66;&#x7684;&#x7528;&#x4F8B;&#x3001;&#x57F7;&#x884C;&#x6E2C;&#x8A66;&#x3001;&#x6536;&#x96C6;&#x6E2C;&#x8A66;&#x7D50;&#x679C;&#x548C;&#x751F;&#x6210;&#x6E2C;&#x8A66;&#x5831;&#x544A;&#x7B49;&#x7B49;&#xFF0C;&#x5C07;&#x958B;&#x767C;&#x7684;&#x6CE8;&#x610F;&#x529B;&#x96C6;&#x4E2D;&#x5728;&#x6E2C;&#x8A66;&#x7684;&#x7528;&#x4F8B;&#x4E0A;&#xFF0C;&#x800C;&#x4E0D;&#x6703;&#x6D6A;&#x8CBB;&#x5728;&#x539F;&#x672C;&#x53EF;&#x4EE5;&#x907F;&#x514D;&#x7684;&#x554F;&#x984C;&#x4E0A;&#x3002;</p>
<h2 id="%E6%A0%B8%E5%BF%83%E5%8A%9F%E8%83%BD">&#x6838;&#x5FC3;&#x529F;&#x80FD;</h2>
<p>Pytest&#x662F;&#x4E00;&#x500B;&#x7528;&#x65BC;Python&#x7A0B;&#x5F0F;&#x8A9E;&#x8A00;&#x7684;&#x6E2C;&#x8A66;&#x6846;&#x67B6;&#x3002;&#x5B83;&#x5141;&#x8A31;&#x958B;&#x767C;&#x8005;&#x64B0;&#x5BEB;&#x7C21;&#x6F54;&#x800C;&#x6709;&#x6548;&#x7684;&#x6E2C;&#x8A66;&#xFF0C;&#x4EE5;&#x78BA;&#x4FDD;&#x4ED6;&#x5011;&#x7684;&#x4EE3;&#x78BC;&#x6B63;&#x78BA;&#x904B;&#x884C;&#x3002;&#x4EE5;&#x4E0B;&#x662F;&#x4E00;&#x4E9B;pytest&#x7684;&#x4E3B;&#x8981;&#x7279;&#x9EDE;&#x548C;&#x529F;&#x80FD;&#xFF1A;</p>
<ol><li>&#x7C21;&#x55AE;&#x6613;&#x7528;&#x3001;&#x5BB9;&#x6613;&#x4E0A;&#x624B;&#x4F7F;&#x7528;&#x6A19;&#x6E96;&#x7684;&#x65B7;&#x8A00;&#x8A9E;&#x53E5;&#x4F86;&#x6AA2;&#x67E5;&#x4EE3;&#x78BC;&#x7684;&#x884C;&#x70BA;&#x662F;&#x5426;&#x7B26;&#x5408;&#x9810;&#x671F;&#x3002;</li><li><a href="https://docs.pytest.org/en/latest/contents.html?ref=ghost.augustushsu.com">&#x6587;&#x4EF6;&#x8C50;&#x5BCC;</a>&#xFF0C;&#x6587;&#x4EF6;&#x4E2D;&#x6709;&#x5F88;&#x591A;&#x4F8B;&#x9805;&#x53EF;&#x4EE5;&#x53C3;&#x8003;&#x3002;</li><li>&#x80FD;&#x5920;&#x652F;&#x63F4;&#x7C21;&#x55AE;&#x7684;&#x55AE;&#x5143;&#x6E2C;&#x8A66;&#x548C;&#x8907;&#x96DC;&#x7684;&#x529F;&#x80FD;&#x6E2C;&#x8A66;&#x3002;</li><li>&#x80FD;&#x5920;&#x81EA;&#x52D5;&#x767C;&#x73FE;&#x548C;&#x57F7;&#x884C;&#x4F60;&#x7684;&#x6E2C;&#x8A66;&#x7528;&#x4F8B;&#xFF0C;&#x53EA;&#x9700;&#x6309;&#x7167;&#x7279;&#x5B9A;&#x7684;&#x547D;&#x540D;&#x898F;&#x5247;&#x4F86;&#x547D;&#x540D;&#x6E2C;&#x8A66;&#x6587;&#x4EF6;&#x548C;&#x51FD;&#x6578;&#xFF0C;pytest&#x5C31;&#x80FD;&#x5920;&#x81EA;&#x52D5;&#x8B58;&#x5225;&#x4E26;&#x904B;&#x884C;&#x5B83;&#x5011;&#x3002;</li><li>&#x5141;&#x8A31;&#x53C3;&#x6578;&#x5316;&#x6E2C;&#x8A66;&#x7528;&#x4F8B;&#xFF0C;&#x9019;&#x610F;&#x5473;&#x8457;&#x60A8;&#x53EF;&#x4EE5;&#x5B9A;&#x7FA9;&#x4E00;&#x500B;&#x6E2C;&#x8A66;&#xFF0C;&#x70BA;&#x4E0D;&#x540C;&#x7684;&#x8F38;&#x5165;&#x53C3;&#x6578;&#x904B;&#x884C;&#x8A72;&#x6E2C;&#x8A66;&#x3002;&#x9019;&#x6709;&#x52A9;&#x65BC;&#x6E2C;&#x8A66;&#x4E0D;&#x540C;&#x60C5;&#x666F;&#x4E0B;&#x7684;&#x4EE3;&#x78BC;&#x884C;&#x70BA;&#x3002;</li><li>&#x652F;&#x63F4;&#x5404;&#x7A2E;&#x63D2;&#x4EF6;&#xFF0C;&#x9019;&#x4E9B;&#x63D2;&#x4EF6;&#x53EF;&#x4EE5;&#x64F4;&#x5C55;pytest&#x7684;&#x529F;&#x80FD;&#xFF0C;&#x4E26;&#x6DFB;&#x52A0;&#x984D;&#x5916;&#x7684;&#x5831;&#x544A;&#x3001;&#x6E2C;&#x8A66;&#x9078;&#x9805;&#x548C;&#x529F;&#x80FD;&#x3002;</li><li>&#x63D0;&#x4F9B;&#x591A;&#x7A2E;&#x5831;&#x544A;&#x683C;&#x5F0F;&#xFF0C;&#x5305;&#x62EC;&#x6587;&#x672C;&#x5831;&#x544A;&#x3001;HTML&#x5831;&#x544A;&#x548C;JUnit XML &#x5831;&#x544A;&#x7B49;&#xFF0C;&#x65B9;&#x4FBF;&#x60A8;&#x67E5;&#x770B;&#x6E2C;&#x8A66;&#x7D50;&#x679C;&#x3002;</li><li>&#x652F;&#x6301;&#x4E26;&#x884C;&#x57F7;&#x884C;&#x6E2C;&#x8A66;&#xFF0C;&#x9019;&#x610F;&#x5473;&#x8457;&#x6E2C;&#x8A66;&#x5957;&#x4EF6;&#x4E2D;&#x7684;&#x591A;&#x500B;&#x6E2C;&#x8A66;&#x7528;&#x4F8B;&#x53EF;&#x4EE5;&#x540C;&#x6642;&#x904B;&#x884C;&#xFF0C;&#x5F9E;&#x800C;&#x7BC0;&#x7701;&#x6642;&#x9593;&#x3002;</li><li>&#x6613;&#x65BC;&#x96C6;&#x6210;&#x5230;&#x6301;&#x7E8C;&#x96C6;&#x6210;&#x548C;&#x6301;&#x7E8C;&#x90E8;&#x7F72; (CI/CD) &#x6D41;&#x6C34;&#x7DDA;&#x4E2D;&#x3002;&#x958B;&#x767C;&#x5718;&#x968A;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;Pytest&#x4F86;&#x78BA;&#x4FDD;&#x6BCF;&#x6B21;&#x4EE3;&#x78BC;&#x66F4;&#x6539;&#x90FD;&#x7D93;&#x904E;&#x5168;&#x9762;&#x7684;&#x6E2C;&#x8A66;&#x3002;</li></ol>
<p>Pytest&#x5B89;&#x88DD;&#x65B9;&#x5F0F;&#x8DDF;&#x4E00;&#x822C;&#x7684;&#x5957;&#x4EF6;&#x5B89;&#x88DD;&#x65B9;&#x5F0F;&#x4E00;&#x6A23;&#xFF0C;&#x4F7F;&#x7528;pip&#x6216;&#x662F;poetry&#x90FD;&#x662F;&#x53EF;&#x4EE5;&#x7684;:</p>
<pre><code class="language-bash">pip install pytest
poetry add pytest</code></pre>
<p>&#x9032;&#x5165;&#x5230;&#x5B89;&#x88DD;&#x4E86;pytest&#x7684;&#x74B0;&#x5883;&#xFF0C;&#x53EF;&#x4EE5;&#x7528;&#x4EE5;&#x4E0B;&#x6307;&#x4EE4;&#x67E5;&#x770B;&#x6709;&#x751A;&#x9EBC;&#x53C3;&#x6578;&#x53EF;&#x4EE5;&#x8A2D;&#x5B9A;:</p>
<pre><code class="language-bash">pytest --help</code></pre>
<h2 id="%E4%BD%BF%E7%94%A8%E6%A1%88%E4%BE%8B">&#x4F7F;&#x7528;&#x6848;&#x4F8B;</h2>
<p>&#x9019;&#x88E1;&#x7C21;&#x55AE;&#x7684;&#x4ECB;&#x7D39;&#x5982;&#x4F55;&#x4F7F;&#x7528;pytest&#x7684;&#x8CC7;&#x6599;&#x593E;&#x7D50;&#x69CB;&#x3001;&#x57FA;&#x790E;&#x4F7F;&#x7528;&#x65B9;&#x6CD5;&#x3001;&#x7522;&#x751F;&#x5831;&#x8868;&#xFF0C;&#x53EA;&#x91DD;&#x5C0D;&#x7C21;&#x55AE;&#x7684;&#x6578;&#x5B78;&#x8A08;&#x7B97;&#x5BEB;&#x6E2C;&#x8A66;&#x6848;&#x4F8B;&#xFF0C;&#x5F8C;&#x7E8C;&#x5982;&#x679C;&#x6709;&#x6642;&#x9593;&#x6703;&#x518D;&#x958B;&#x4E00;&#x7BC7;&#x91DD;&#x5C0D;&#x5F8C;&#x7AEF;&#x3001;&#x8CC7;&#x6599;&#x5EAB;&#x5BEB;&#x6E2C;&#x8A66;&#x7BC4;&#x4F8B;&#x7684;&#x7D00;&#x9304;&#x3002;</p>
<h3 id="%E8%B3%87%E6%96%99%E5%A4%BE%E7%B5%90%E6%A7%8B">&#x8CC7;&#x6599;&#x593E;&#x7D50;&#x69CB;</h3>
<p>&#x9996;&#x5148;&#x5275;&#x5EFA;&#x4E00;&#x500B;<code>test</code>&#x8CC7;&#x6599;&#x593E;&#xFF0C;&#x7528;&#x4F5C;&#x5B58;&#x653E;&#x6E2C;&#x8A66;&#x7684;&#x7528;&#x4F8B;&#x65B9;&#x4FBF;&#x7BA1;&#x7406;&#x3002;pytest&#x9810;&#x8A2D;&#x6703;&#x81EA;&#x52D5;&#x628A;&#x76EE;&#x9304;&#x88E1;&#x6240;&#x6709;&#x540D;&#x7A31;&#x70BA;<code>test_*.py</code>&#x7684;&#x6A94;&#x6848;&#x5168;&#x90FD;&#x6E2C;&#x8A66;&#x4E00;&#x904D;&#xFF0C;&#x6240;&#x4EE5;&#x7528;&#x4F5C;&#x6E2C;&#x8A66;&#x7684;&#x6A94;&#x6848;&#x8981;&#x4EE5;<code>test_</code>&#x958B;&#x982D;&#x547D;&#x540D;&#x3002;</p>
<p>&#x5C08;&#x6848;&#x4E2D;&#x5E38;&#x898B;&#x7684;&#x8CC7;&#x6599;&#x593E;&#x7D50;&#x69CB;&#x5927;&#x81F4;&#x4E0A;&#x5206;&#x70BA;&#x5169;&#x7A2E;&#xFF0C;&#x4E00;&#x7A2E;&#x662F;&#x653E;&#x5728;&#x61C9;&#x7528;&#x7A0B;&#x5F0F;&#x7A0B;&#x5F0F;&#x78BC;&#x4E4B;&#x5916;&#x7684;&#x6E2C;&#x8A66;&#xFF0C;&#x9019;&#x7A2E;&#x65B9;&#x6848;&#x7684;&#x597D;&#x8655;&#x5F88;&#x660E;&#x986F;&#xFF0C;&#x9019;&#x4E9B;&#x6E2C;&#x8A66;&#x6848;&#x4F8B;&#x7368;&#x7ACB;&#x65BC;&#x5957;&#x4EF6;&#xFF0C;&#x7C21;&#x5316;&#x4E86;&#x6E2C;&#x8A66;&#x7684;&#x7D44;&#x7E54;&#x67B6;&#x69CB;&#xFF0C;&#x53EF;&#x4EE5;&#x5C07;&#x6240;&#x6709;&#x6E2C;&#x8A66;&#x90FD;&#x96C6;&#x4E2D;&#x5728;<code>test</code>&#x8CC7;&#x6599;&#x593E;&#x5167;&#x55AE;&#x7368;&#x6E2C;&#x8A66;&#xFF0C;&#x4E0D;&#x9700;&#x8981;&#x8003;&#x616E;&#x5C08;&#x6848;&#x5167;&#x7684;&#x5C64;&#x6B21;&#x7D50;&#x69CB;:</p>
<pre><code class="language-bash">&#x251C;&#x2500;src
&#x2502;  &#x2514;&#x2500;pkg
&#x2502;     &#x251C;&#x2500;__init__.py
&#x2502;     &#x251C;&#x2500;module_a.py
&#x2502;     &#x2514;&#x2500;module_b.py
&#x251C;&#x2500;tests
&#x2502;  &#x251C;&#x2500;__init__.py
&#x2502;  &#x251C;&#x2500;test_module_a.py
&#x2502;  &#x2514;&#x2500;test_module_b.py
&#x2514;&#x2500;setup.py</code></pre>
<p>&#x5982;&#x679C;&#x6E2C;&#x8A66;&#x548C;&#x4F60;&#x7684;&#x5C08;&#x6848;&#x5BC6;&#x5207;&#x76F8;&#x95DC;&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x5C07;&#x6E2C;&#x8A66;&#x6848;&#x4F8B;&#x4F5C;&#x70BA;&#x5C08;&#x6848;&#x7A0B;&#x5F0F;&#x78BC;&#x7684;&#x4E00;&#x90E8;&#x5206;&#xFF0C;&#x9019;&#x6A23;&#x53EF;&#x4EE5;&#x66F4;&#x597D;&#x5730;&#x7D44;&#x7E54;&#x7A0B;&#x5F0F;&#x78BC;&#xFF0C;&#x4E26;&#x4E14;&#x56E0;&#x70BA;&#x5728;&#x540C;&#x4E00;&#x500B;&#x8CC7;&#x6599;&#x593E;&#x5167;&#x4FBF;&#x65BC;&#x7DAD;&#x8B77;:</p>
<pre><code class="language-bash">&#x251C;&#x2500;src
&#x2502;  &#x251C;&#x2500;pkg
&#x2502;  &#x2502;  &#x251C;&#x2500;__init__.py
&#x2502;  &#x2502;  &#x251C;&#x2500;module_a.py
&#x2502;  &#x2502;  &#x2514;&#x2500;module_b.py
&#x2502;  &#x2514;&#x2500;tests
&#x2502;     &#x251C;&#x2500;test_module_a.py
&#x2502;     &#x2514;&#x2500;test_module_b.py
&#x2514;&#x2500;setup.py</code></pre>
<p>&#x53EA;&#x8981;&#x5718;&#x968A;&#x5167;&#x6709;&#x5171;&#x8B58;&#xFF0C;&#x7121;&#x8AD6;&#x9078;&#x64C7;&#x54EA;&#x4E00;&#x7A2E;pytest&#x90FD;&#x53EF;&#x4EE5;&#x9032;&#x884C;&#x8B58;&#x5225;&#x548C;&#x6E2C;&#x8A66;&#xFF0C;&#x6700;&#x91CD;&#x8981;&#x7684;&#x662F;&#x78BA;&#x4FDD;&#x6E2C;&#x8A66;&#x7684;&#x7D44;&#x7E54;&#x7D50;&#x69CB;&#x6E05;&#x6670;&#x4E14;&#x6613;&#x65BC;&#x7DAD;&#x8B77;&#x5373;&#x53EF;&#x3002;</p>
<p>&#x53EF;&#x4EE5;&#x770B;&#x5230;<code>test</code>&#x5167;&#x6709;<code>__init__.py</code>&#xFF0C;&#x9019;&#x662F;&#x70BA;&#x4E86;&#x5C07;<code>test</code>&#x8996;&#x70BA;&#x4E00;&#x500B;python&#x7684;package&#xFF0C;&#x4F7F;&#x5F97;pytest&#x80FD;&#x5920;&#x5728;&#x5176;&#x4E2D;&#x8B58;&#x5225;&#x548C;&#x57F7;&#x884C;&#x6E2C;&#x8A66;&#x6587;&#x4EF6;&#xFF0C;&#x6709;&#x52A9;&#x65BC;&#x66F4;&#x597D;&#x5730;&#x7D44;&#x7E54;&#x60A8;&#x7684;&#x6E2C;&#x8A66;&#x4EE3;&#x78BC;&#xFF0C;&#x4F7F;&#x5176;&#x66F4;&#x6613;&#x65BC;&#x7BA1;&#x7406;&#x548C;&#x7DAD;&#x8B77;&#x3002;</p>
<h3 id="%E7%B0%A1%E5%96%AE%E7%AF%84%E4%BE%8B">&#x7C21;&#x55AE;&#x7BC4;&#x4F8B;</h3>
<p>&#x5275;&#x5EFA;&#x4E00;&#x500B;Python&#x6587;&#x4EF6; <code>calculator.py</code>&#xFF0C;&#x5176;&#x4E2D;&#x5305;&#x542B;&#x8981;&#x6E2C;&#x8A66;&#x7684;&#x51FD;&#x6578;&#xFF1A;</p>
<pre><code class="language-python"># calculator.py

def add(a, b):
    return a + b</code></pre>
<p>&#x7136;&#x5F8C;&#x5275;&#x5EFA;&#x4E00;&#x500B;&#x6E2C;&#x8A66;&#x6587;&#x4EF6; <code>test_calculator.py</code>&#xFF0C;&#x5176;&#x4E2D;&#x5305;&#x542B;&#x6E2C;&#x8A66;&#x7528;&#x4F8B;&#xFF1A;</p>
<pre><code class="language-python"># test_calculator.py

import calculator

def test_add_positive_numbers():
    assert calculator.add(2, 3) == 5

def test_add_negative_numbers():
    assert calculator.add(-2, -3) == -5

def test_add_mixed_numbers():
    assert calculator.add(5, -3) == 2

def test_add_zero():
    assert calculator.add(0, 0) == 0</code></pre>
<p>&#x5728;&#x9019;&#x500B;&#x4F8B;&#x5B50;&#x4E2D;&#xFF0C;&#x5275;&#x5EFA;&#x4E86;&#x56DB;&#x500B;&#x6E2C;&#x8A66;&#x7528;&#x4F8B;&#xFF0C;&#x5206;&#x5225;&#x6E2C;&#x8A66;&#x4E86; <code>add</code> &#x51FD;&#x6578;&#x7684;&#x4E0D;&#x540C;&#x60C5;&#x666F;&#xFF1A;&#x5169;&#x500B;&#x6B63;&#x6578;&#x76F8;&#x52A0;&#x3001;&#x5169;&#x500B;&#x8CA0;&#x6578;&#x76F8;&#x52A0;&#x3001;&#x4E00;&#x500B;&#x6B63;&#x6578;&#x548C;&#x4E00;&#x500B;&#x8CA0;&#x6578;&#x76F8;&#x52A0;&#xFF0C;&#x4EE5;&#x53CA;&#x5169;&#x500B;&#x96F6;&#x76F8;&#x52A0;&#x3002;<strong>&#x5207;&#x63DB;&#x5230;&#x5305;&#x542B;&#x6E2C;&#x8A66;&#x8CC7;&#x6599;&#x593E;&#x7684;&#x8DEF;&#x5F91;</strong>&#x904B;&#x884C;pytest&#xFF0C;pytest&#x6703;&#x81EA;&#x52D5;&#x767C;&#x73FE;&#x4E26;&#x904B;&#x884C; <code>test_calculator.py</code> &#x7684;&#x6E2C;&#x8A66;&#x7528;&#x4F8B;&#xFF0C;&#x4E26;&#x4E14;&#x5831;&#x544A;&#x7D50;&#x679C;&#xFF0C;&#x5982;&#x679C;&#x4E00;&#x5207;&#x6B63;&#x78BA;&#x61C9;&#x8A72;&#x6703;&#x770B;&#x5230;&#x985E;&#x4F3C;&#x4EE5;&#x4E0B;&#x7684;&#x8F38;&#x51FA;&#xFF1A;</p>
<pre><code class="language-bash">======================= test session starts =======================
platform win32 -- Python 3.10.10, pytest-7.4.2, pluggy-1.3.0        
rootdir: /path/to/your/tests
collected 4 items                                                   

tests\test_calculator.py ....                                [100%] 

======================== 4 passed in 0.02s ========================</code></pre>
<p>&#x9019;&#x8AAA;&#x660E;&#x6240;&#x6709;&#x56DB;&#x500B;&#x6E2C;&#x8A66;&#x7528;&#x4F8B;&#x90FD;&#x6210;&#x529F;&#x901A;&#x904E;&#xFF0C;&#x5982;&#x679C;&#x5176;&#x4E2D;&#x4EFB;&#x4F55;&#x4E00;&#x500B;&#x6E2C;&#x8A66;&#x5931;&#x6557;&#xFF0C;Pytest&#x6703;&#x5831;&#x544A;&#x76F8;&#x95DC;&#x7684;&#x8A73;&#x7D30;&#x4FE1;&#x606F;&#xFF0C;&#x5E6B;&#x52A9;&#x60A8;&#x5FEB;&#x901F;&#x5B9A;&#x4F4D;&#x554F;&#x984C;&#x3002;&#x9019;&#x7A2E;&#x6E2C;&#x8A66;&#x65B9;&#x5F0F;&#x6709;&#x52A9;&#x65BC;&#x78BA;&#x4FDD; <code>add</code> &#x51FD;&#x6578;&#x7684;&#x6B63;&#x78BA;&#x6027;&#x3002;</p>
<h3 id="class%E7%AF%84%E4%BE%8B">Class&#x7BC4;&#x4F8B;</h3>
<p>&#x9664;&#x4E86;&#x524D;&#x9762;&#x4ECB;&#x7D39;&#x7684;&#x65B9;&#x5F0F;&#x4F86;&#x4F7F;&#x7528;pytest&#x4EE5;&#x5916;&#xFF0C;&#x9084;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;class&#x7684;&#x5F62;&#x5F0F;&#x4F86;&#x7D44;&#x7E54;&#x6E2C;&#x8A66;&#xFF0C;&#x9019;&#x7A31;&#x70BA; &quot;&#x985E;&#x7D1A;&#x5225;&#x7684;&#x6E2C;&#x8A66;&quot;&#xFF0C;&#x9019;&#x5C0D;&#x65BC;&#x5728;&#x591A;&#x500B;&#x6E2C;&#x8A66;&#x4E4B;&#x9593;&#x5171;&#x4EAB;&#x8A2D;&#x7F6E;&#x6216;&#x8CC7;&#x6E90;&#x7279;&#x5225;&#x6709;&#x7528;&#x3002;&#x4EE5;&#x4E0B;&#x662F;&#x4E00;&#x500B;&#x793A;&#x4F8B;&#xFF0C;&#x5C55;&#x793A;&#x4E86;&#x5982;&#x4F55;&#x4F7F;&#x7528;&#x985E;&#x9032;&#x884C;&#x6E2C;&#x8A66;&#x4EE5;&#x53CA;&#x76F8;&#x61C9;&#x7684;&#x88AB;&#x6E2C;&#x8A66;&#x4EE3;&#x78BC;&#x3002;</p>
<p>&#x5275;&#x5EFA;&#x4E00;&#x500B; <code>test_cls_calculator.py</code> &#x6E2C;&#x8A66;&#x6587;&#x4EF6;&#xFF0C;&#x4F7F;&#x7528;&#x985E;&#x7684;&#x5F62;&#x5F0F;&#x9032;&#x884C;&#x6E2C;&#x8A66;&#xFF1A;</p>
<pre><code class="language-python"># test_cls_calculator.py

import pytest
import calculator

class TestCalculator:
    def test_add_positive_numbers(self):
        result = calculator.add(2, 3)
        assert result == 5

    def test_add_negative_numbers(self):
        result = calculator.add(-2, -3)
        assert result == -5

    def test_add_mixed_numbers(self):
        result = calculator.add(5, -3)
        assert result == 2

    def test_add_zero(self):
        result = calculator.add(0, 0)
        assert result == 0</code></pre>
<p>&#x9019;&#x7A2E;&#x65B9;&#x6CD5;&#x7279;&#x5225;&#x9069;&#x7528;&#x65BC;&#x8907;&#x96DC;&#x7684;&#x6E2C;&#x8A66;&#x5834;&#x666F;&#xFF0C;&#x70BA;&#x4E0D;&#x540C;&#x6E2C;&#x8A66;&#x65B9;&#x6CD5;&#x4E4B;&#x9593;&#x5171;&#x4EAB;&#x8A2D;&#x7F6E;&#x548C;&#x8CC7;&#x6E90;&#x3002;</p>
<h3 id="setup-teardown">setup &amp; teardown</h3>
<p><code>setup</code>&#x548C;<code>teardown</code>&#x662F;&#x5E38;&#x898B;&#x7528;&#x65BC;&#x6E2C;&#x8A66;&#x7528;&#x4F8B;&#x7684;&#x9810;&#x8A2D;&#x5B9A;&#x548C;&#x6E05;&#x7406;&#x8A2D;&#x5B9A;&#x7684;&#x6982;&#x5FF5;&#xFF0C;&#x5728;&#x57F7;&#x884C;&#x6E2C;&#x8A66;&#x7528;&#x4F8B;&#x4E4B;&#x524D;&#x9032;&#x884C;&#x4E00;&#x4E9B;&#x74B0;&#x5883;&#x8A2D;&#x5B9A;&#x3001;&#x521D;&#x59CB;&#x5316;&#x7B49;&#x7B49;&#xFF0C;&#x4EE5;&#x53CA;&#x5728;&#x6E2C;&#x8A66;&#x57F7;&#x884C;&#x5F8C;&#x9032;&#x884C;&#x6E05;&#x7406;&#x7684;&#x5DE5;&#x4F5C;&#x3002;&#x5728;pytest&#x4E2D;&#x63D0;&#x4F9B;&#x4E86;&#x8A31;&#x591A;&#x65B9;&#x6CD5;&#x4F86;&#x5BE6;&#x73FE;&#x9019;&#x4E9B;&#x8A2D;&#x5B9A;&#x548C;&#x6E05;&#x7406;&#x7684;&#x64CD;&#x4F5C;&#xFF0C;&#x5305;&#x62EC;<code>setup</code>&#x3001;<code>teardown</code>&#x548C;&#x5F8C;&#x7E8C;&#x8981;&#x4ECB;&#x7D39;&#x7684;<code>Fixture</code>&#x3002;</p>
<p><code>setup</code>&#x548C;<code>teardown</code>&#x4E0D;&#x80FD;&#x76F4;&#x63A5;&#x4F7F;&#x7528;&#xFF0C;&#x8981;&#x5728;&#x5F8C;&#x9762;&#x52A0;&#x4E0A;&#x6E2C;&#x8A66;&#x9032;&#x884C;&#x6642;&#x7684;&#x4F5C;&#x7528;&#x57DF;&#xFF0C;&#x5206;&#x5225;&#x662F;&#x4EE5;&#x4E0B;&#x9019;&#x56DB;&#x7A2E;:</p>
<ol><li>function: &#x51FD;&#x6578;&#x7D1A;&#x5225;&#xFF0C;&#x5728;&#x6BCF;&#x6B21;&#x51FD;&#x6578;&#x958B;&#x59CB;&#x548C;&#x7D50;&#x675F;&#x6642;&#x904B;&#x884C;&#x3002;</li><li>method: &#x65B9;&#x6CD5;&#x7D1A;&#x5225;&#xFF0C;class&#x4E2D;&#x4F7F;&#x7528;&#xFF0C;&#x5728;&#x985E;&#x5225;&#x5167;method&#x88AB;&#x8ABF;&#x7528;&#x7684;&#x958B;&#x59CB;&#x548C;&#x7D50;&#x675F;&#x6642;&#x904B;&#x884C;&#x3002;</li><li>class: &#x985E;&#x5225;&#x7D1A;&#x5225;&#xFF0C;&#x4E00;&#x6A23;&#x5728;class&#x4E2D;&#x4F7F;&#x7528;&#xFF0C;&#x5728;&#x985E;&#x5225;&#x958B;&#x59CB;&#x548C;&#x7D50;&#x675F;&#x6642;&#x904B;&#x884C;&#x3002;</li><li>module: &#x6A21;&#x7D44;&#x7D1A;&#x5225;&#xFF0C;&#x5728;&#x6574;&#x500B;.py&#x6A21;&#x7D44;&#x958B;&#x59CB;&#x548C;&#x7D50;&#x675F;&#x6642;&#x904B;&#x884C;&#x3002;</li></ol>
<p>&#x4F7F;&#x7528;&#x65B9;&#x5F0F;&#x5927;&#x81F4;&#x5982;&#x4E0B;:</p>
<pre><code class="language-python"># test_calculator.py

from src.package import calculator


def setup_module():
    print()
    print(&quot;setup_module&quot;)


def teardown_module():
    print()
    print(&quot;teardown_module&quot;)


def setup_function():
    print()
    print(&quot;setup_function&quot;)


def teardown_function():
    print()
    print(&quot;teardown_function&quot;)


def test_add_positive_numbers():
    assert calculator.add(2, 3) == 5


def test_add_negative_numbers():
    assert calculator.add(-2, -3) == -5


def test_add_mixed_numbers():
    assert calculator.add(5, -3) == 2


def test_add_zero():
    assert calculator.add(0, 0) == 0
</code></pre>
<p>&#x5982;&#x679C;&#x662F;class&#x7684;&#x8A71;&#x5247;&#x662F;:</p>
<pre><code class="language-python"># test_cls_calculator.py
import pytest

from src.package import calculator


def setup_module():
    print()
    print(&quot;setup_module&quot;)


def teardown_module():
    print()
    print(&quot;teardown_module&quot;)


class TestCalculator:
    def setup_class(self):
        print()
        print(&quot;setup_class&quot;)

    def teardown_class(self):
        print()
        print(&quot;teardown_class&quot;)

    def setup_method(self):
        print()
        print(&quot;setup_method&quot;)

    def teardown_method(self):
        print()
        print(&quot;teardown_method&quot;)

    def test_add_positive_numbers(self):
        result = calculator.add(2, 3)
        assert result == 5

    def test_add_negative_numbers(self):
        result = calculator.add(-2, -3)
        assert result == -5

    def test_add_mixed_numbers(self):
        result = calculator.add(5, -3)
        assert result == 2

    def test_add_zero(self):
        result = calculator.add(0, 0)
        assert result == 0


if __name__ == &quot;__main__&quot;:
    pytest.main()
</code></pre>
<p>&#x7D50;&#x679C;&#x5982;&#x4E0B;&#xFF0C;&#x6BCF;&#x4E00;&#x500B;&#x9EDE;&#x4EE3;&#x8868;&#x7684;&#x662F;&#x4E00;&#x500B;&#x901A;&#x904E;&#x7684;&#x6E2C;&#x8A66;:</p>
<pre><code class="language-python">======================= test session starts =======================
platform win32 -- Python 3.10.10, pytest-7.4.2, pluggy-1.3.0        
rootdir: /path/to/your/tests
collected 8 items

tests\test_calculator.py
setup_module

setup_function
.
teardown_function

setup_function
.
teardown_function

setup_function
.
teardown_function

setup_function
.
teardown_function

teardown_module

tests\test_cls_calculator.py
setup_module

setup_class

setup_method
.
teardown_method

setup_method
.
teardown_method

setup_method
.
teardown_method

setup_method
.
teardown_method

teardown_class

teardown_module


======================== 8 passed in 0.06s ======================== </code></pre>
<p>&#x5982;&#x679C;&#x8981;&#x5728;&#x547D;&#x4EE4;&#x5217;&#x770B;&#x5230;&#x5B9A;&#x7FA9;&#x7684;<code>setup</code>&#x548C;<code>teardown</code>&#x4E2D;&#x6240;print&#x7684;&#x5167;&#x5BB9;&#xFF0C;&#x5728;&#x6E2C;&#x8A66;&#x7684;&#x6642;&#x5019;&#x8A18;&#x5F97;&#x5728;pytest&#x5F8C;&#x9762;&#x52A0;&#x4E0A;<code>-s</code>&#x624D;&#x80FD;&#x770B;&#x5230;<code>setup</code>&#x548C;<code>teardown</code> print&#x51FA;&#x4F86;&#x7684;&#x8CC7;&#x8A0A;&#x3002;</p>
<h3 id="%E5%8F%83%E6%95%B8%E5%8C%96">&#x53C3;&#x6578;&#x5316;</h3>
<p>&#x7576;&#x9700;&#x8981;&#x5C0D;&#x540C;&#x4E00;&#x7D44;&#x51FD;&#x6578;&#x6E2C;&#x8A66;&#x591A;&#x7D44;&#x6E2C;&#x8A66;&#x6848;&#x4F8B;&#x6642;&#xFF0C;&#x53EF;&#x4EE5;&#x900F;&#x904E;pytest&#x7684;<code>@pytest.mark.parametrize</code>&#x9019;&#x500B;&#x88DD;&#x98FE;&#x5668;&#x4F86;&#x8A2D;&#x5B9A;&#xFF0C;&#x53EF;&#x4EE5;&#x8A2D;&#x5B9A;&#x591A;&#x7D44;&#x7684;&#x8F38;&#x5165;&#x53C3;&#x6578;&#x548C;&#x9810;&#x671F;&#x8F38;&#x51FA;&#xFF0C;pytest&#x6703;&#x81EA;&#x52D5;&#x904B;&#x884C;&#x6E2C;&#x8A66;&#x7528;&#x4F8B;&#x7684;&#x591A;&#x500B;&#x904B;&#x884C;&#x5BE6;&#x4F8B;&#xFF0C;&#x6BCF;&#x500B;&#x5BE6;&#x4F8B;&#x4F7F;&#x7528;&#x4E0D;&#x540C;&#x7684;&#x8F38;&#x5165;&#x53C3;&#x6578;&#x3002;</p>
<p>&#x5728;&#x4E0B;&#x9762;&#x7684;&#x7A0B;&#x5F0F;&#x78BC;&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x900F;&#x904E;&#x8B80;&#x53D6;json&#x6A94;&#x6848;&#x7372;&#x53D6;&#x8F38;&#x5165;&#x53C3;&#x6578;&#x548C;&#x9810;&#x671F;&#x8F38;&#x51FA;&#xFF0C;&#x8A2D;&#x5B9A;<code>argnames</code>&#x8DDF;<code>argvalues</code>&#x4F86;&#x6307;&#x5B9A;&#x8B8A;&#x6578;&#x540D;&#x7A31;&#x8DDF;&#x8F38;&#x5165;&#x8B8A;&#x6578;&#xFF0C;&#x7136;&#x5F8C;&#x53EF;&#x4EE5;&#x6307;&#x5B9A;&#x6BCF;&#x7D44;&#x7684;&#x6E2C;&#x8A66;&#x540D;&#x7A31;<code>ids</code>&#x4F86;&#x5340;&#x5206;&#x4E0D;&#x540C;&#x7684;&#x6E2C;&#x8A66;&#x5BE6;&#x4F8B;&#xFF0C;&#x6700;&#x5F8C;&#x5B9A;&#x7FA9;&#x51FA;&#x6E2C;&#x8A66;&#x51FD;&#x6578;:</p>
<pre><code class="language-python"># test_calculator.py

import json

import pytest

from src.package import calculator

with open(&quot;tests/test_calculator/test_calculator_args.json&quot;, &quot;r&quot;, encoding=&quot;utf8&quot;) as file:
    calculator_test_case = json.loads(file.read())[&quot;calculator_test_case&quot;]


ids = [f&quot;case: {idx}&quot; for idx in range(1, len(calculator_test_case) + 1)]


@pytest.mark.parametrize(
    argnames=&quot;input_a, input_b, expected_output&quot;, argvalues=calculator_test_case, ids=ids
)
def test_add_positive_numbers(input_a: int, input_b: int, expected_output: int):
    assert calculator.add(input_a, input_b) == expected_output

</code></pre>
<p>&#x4E0B;&#x65B9;&#x662F;&#x6E2C;&#x8A66;&#x8CC7;&#x6599;<code>test_calculator_args.json</code>&#x7684;&#x5167;&#x5BB9;:</p>
<pre><code class="language-json">{
    &quot;calculator_test_case&quot;: [
        [2, 3, 5],
        [-2, -3, -5],
        [5, -3, 2],
        [0, 0, 0]
    ]
}
</code></pre>
<p>&#x6700;&#x5F8C;pytest&#x7684;&#x8F38;&#x51FA;&#x7D50;&#x679C;&#xFF0C;&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x6BCF;&#x7B46;&#x6E2C;&#x8A66;&#x8CC7;&#x6599;&#x90FD;&#x5C0D;&#x61C9;&#x4E00;&#x500B;&#x6E2C;&#x8A66;&#x5BE6;&#x4F8B;&#xFF0C;&#x540D;&#x7A31;<code>ids</code>&#x4E5F;&#x986F;&#x793A;&#x5728;&#x7D50;&#x679C;&#x4E0A;:</p>
<pre><code class="language-bash">===================================== test session starts =====================================
platform win32 -- Python 3.10.10, pytest-7.4.2, pluggy-1.3.0        
rootdir: /path/to/your/tests
collected 4 items                                                                               

tests/test_calculator/test_param_calculator.py::test_add_positive_numbers[case: 1] PASSED [ 25%]
tests/test_calculator/test_param_calculator.py::test_add_positive_numbers[case: 2] PASSED [ 50%]
tests/test_calculator/test_param_calculator.py::test_add_positive_numbers[case: 3] PASSED [ 75%]
tests/test_calculator/test_param_calculator.py::test_add_positive_numbers[case: 4] PASSED [100%]
====================================== 4 passed in 0.03s ======================================</code></pre>
<h3 id="%E9%A9%97%E8%AD%89%E9%8C%AF%E8%AA%A4">&#x9A57;&#x8B49;&#x932F;&#x8AA4;</h3>
<p>&#x5728;&#x5C08;&#x6848;&#x4E2D;&#x6709;&#x6642;&#x6703;&#x9700;&#x8981;&#x8A2D;&#x8A08;&#x4E00;&#x4E9B;&#x9810;&#x671F;&#x5167;&#x7684;&#x932F;&#x8AA4;&#xFF0C;&#x50CF;&#x662F;&#x7121;&#x6548;&#x7684;&#x8F38;&#x5165;&#x3001;&#x908A;&#x754C;&#x689D;&#x4EF6;&#x6216;&#x662F;&#x4E0D;&#x5408;&#x7406;&#x7684;&#x64CD;&#x4F5C;&#x7B49;&#x7B49;&#xFF0C;&#x9019;&#x4E9B;&#x5C31;&#x662F;&#x5408;&#x7406;&#x3001;&#x9810;&#x671F;&#x5167;&#x7684;&#x932F;&#x8AA4;&#xFF0C;pytest&#x6709;&#x9A57;&#x8B49;&#x932F;&#x8AA4;&#x7684;&#x529F;&#x80FD;&#x4F86;&#x78BA;&#x4FDD;&#x61C9;&#x7528;&#x7A0B;&#x5F0F;&#x5728;&#x9047;&#x5230;&#x932F;&#x8AA4;&#x6642;&#x4E0D;&#x6703;&#x5D29;&#x6F70;&#x6216;&#x7522;&#x751F;&#x4E0D;&#x7B26;&#x9810;&#x671F;&#x7684;&#x7D50;&#x679C;&#x3002;</p>
<p>&#x5EFA;&#x7ACB;&#x4E00;&#x500B;&#x6E2C;&#x8A66;&#x7528;&#x4F8B;&#xFF0C;&#x7528;<code>pytest.raises</code>&#x6355;&#x7372;<code>ValueError</code>&#x78BA;&#x4FDD;&#x5F15;&#x767C;&#x4E86;&#x9810;&#x671F;&#x7684;&#x932F;&#x8AA4;:</p>
<pre><code class="language-python"># test_error.py

import pytest


def test_value_error():
    with pytest.raises(ValueError):
        raise ValueError(&quot;This is a test error&quot;)</code></pre>
<p>&#x9664;&#x4E86;&#x9A57;&#x8B49;&#x932F;&#x8AA4;&#x4EE5;&#x5916;&#xFF0C;pytest&#x9084;&#x53EF;&#x4EE5;&#x6AA2;&#x67E5;&#x932F;&#x8AA4;&#x8A0A;&#x606F;&#x662F;&#x5426;&#x7B26;&#x5408;&#x9810;&#x671F;:</p>
<pre><code class="language-python">def test_value_error_msg():
    with pytest.raises(ValueError) as exc_info:
        raise ValueError(&quot;This is a test error&quot;)

    assert str(exc_info.value) == &quot;This is a test error&quot;

    assert exc_info.typename == ValueError.__name__</code></pre>
<h3 id="%E8%B7%B3%E9%81%8E%E6%B8%AC%E8%A9%A6">&#x8DF3;&#x904E;&#x6E2C;&#x8A66;</h3>
<p>&#x5728;&#x8EDF;&#x9AD4;&#x958B;&#x767C;&#x4E2D;&#xFF0C;&#x6709;&#x6642;&#x5019;&#x53EF;&#x80FD;&#x9700;&#x8981;&#x8DF3;&#x904E;&#x6E2C;&#x8A66;&#xFF0C;&#x5982;&#x5C1A;&#x672A;&#x5BE6;&#x73FE;&#x7684;&#x529F;&#x80FD;&#x3001;&#x81E8;&#x6642;&#x6027;&#x7684;&#x554F;&#x984C;&#x3001;&#x7279;&#x5B9A;&#x5E73;&#x53F0;&#x6216;&#x662F;&#x74B0;&#x5883;&#x3001;&#x5F85;&#x89E3;&#x6C7A;&#x7684;&#x554F;&#x984C;&#x7B49;&#x7B49;&#xFF0C;&#x78B0;&#x5230;&#x9019;&#x4E9B;&#x60C5;&#x6CC1;pytest&#x63D0;&#x4F9B;&#x4E86;&#x8DF3;&#x904E;&#x7684;&#x529F;&#x80FD;<code>skip</code>&#x548C;<code>skipif</code>&#xFF0C;&#x5982;&#x4E0B;:</p>
<pre><code class="language-python"># test_skip.py

import sys

import pytest


@pytest.mark.skip(reason=&quot;This test is not implemented yet&quot;)
def test_unimplemented_feature():
    # &#x5C1A;&#x672A;&#x5BE6;&#x4F5C;&#x8A72;&#x6E2C;&#x8A66;&#xFF0C;&#x5148;&#x8DF3;&#x904E;
    pass


@pytest.mark.skipif(condition=sys.platform == &quot;win32&quot;, reason=&quot;Conditionally skipped test&quot;)
def test_conditionally_skipped_feature():
    # &#x7576;&#x7CFB;&#x7D71;&#x70BA;win32&#x6642;&#x8DF3;&#x904E;
    pass
</code></pre>
<p>&#x8981;&#x6CE8;&#x610F;&#x96D6;&#x7136;&#x8DF3;&#x904E;&#x6E2C;&#x8A66;&#x5728;&#x67D0;&#x4E9B;&#x60C5;&#x6CC1;&#x4E0B;&#x662F;&#x5408;&#x7406;&#x7684;&#xFF0C;&#x4F46;&#x4E0D;&#x61C9;&#x8A72;&#x6210;&#x70BA;&#x6A19;&#x6E96;&#x4F5C;&#x6CD5;&#xFF0C;&#x61C9;&#x8A72;&#x81F4;&#x529B;&#x65BC;&#x89E3;&#x6C7A;&#x8DF3;&#x904E;&#x6E2C;&#x8A66;&#x7684;&#x539F;&#x56E0;&#xFF0C;&#x4E26;&#x78BA;&#x4FDD;&#x6E2C;&#x8A66;&#x5957;&#x4EF6;&#x662F;&#x5B8C;&#x6574;&#x7684;&#xFF0C;&#x53EF;&#x4EE5;&#x6B63;&#x78BA;&#x7684;&#x9A57;&#x8B49;&#x61C9;&#x7528;&#x7A0B;&#x5E8F;&#x7684;&#x529F;&#x80FD;&#xFF0C;&#x5426;&#x5247;&#x9577;&#x671F;&#x8DF3;&#x904E;&#x6E2C;&#x8A66;&#x53EF;&#x80FD;&#x6703;&#x5C0E;&#x81F4;&#x554F;&#x984C;&#x7D2F;&#x7A4D;&#x4E26;&#x964D;&#x4F4E;&#x7A0B;&#x5F0F;&#x78BC;&#x7684;&#x53EF;&#x9760;&#x6027;&#x3002;</p>
<h2 id="%E5%B8%B8%E7%94%A8%E6%8C%87%E4%BB%A4">&#x5E38;&#x7528;&#x6307;&#x4EE4;</h2>
<p>&#x9019;&#x88E1;&#x4ECB;&#x7D39;&#x5E7E;&#x500B;&#x5728;&#x6E2C;&#x8A66;&#x6642;&#x5E38;&#x7528;&#x5230;&#x7684;&#x6307;&#x4EE4;:</p>
<ol><li><code>pytest -v</code>: &#x986F;&#x793A;&#x8A73;&#x7D30;&#x7684;&#x8F38;&#x51FA;&#xFF0C;&#x5305;&#x542B;&#x6BCF;&#x500B;&#x6E2C;&#x8A66;&#x7684;&#x540D;&#x7A31;&#x548C;&#x7D50;&#x679C;&#x3002;</li><li><code>pytest -s</code>: &#x5728;&#x904B;&#x884C;&#x6E2C;&#x8A66;&#x6642;&#x986F;&#x793A;&#x6A19;&#x6E96;&#x8F38;&#x51FA; (<strong>stdout</strong>)&#xFF0C;&#x901A;&#x5E38;&#x50C5;&#x5728;&#x8ABF;&#x8A66;&#x6216;&#x6AA2;&#x67E5;&#x6E2C;&#x8A66;&#x8F38;&#x51FA;&#x6642;&#x4F7F;&#x7528;&#xFF0C;&#x4E0D;&#x7136;&#x53EF;&#x80FD;&#x6703;&#x964D;&#x4F4E;&#x6E2C;&#x8A66;&#x5831;&#x544A;&#x7684;&#x53EF;&#x8B80;&#x6027;&#x3002;</li><li><code>pytest -r</code>: &#x7528;&#x65BC;&#x6307;&#x5B9A;&#x6E2C;&#x8A66;&#x5831;&#x544A;&#x7684;&#x986F;&#x793A;&#x7D1A;&#x5225;&#xFF0C;<code>-r f</code>&#x986F;&#x793A;&#x5931;&#x6557;&#x7684;&#x6E2C;&#x8A66; (&#x7C21;&#x55AE;&#x5831;&#x544A;)&#xFF1B;<code>-r a</code>&#x986F;&#x793A;&#x6240;&#x6709;&#x6E2C;&#x8A66; (&#x5E38;&#x898F;&#x5831;&#x544A;)&#xFF1B;<code>-r A</code>&#x986F;&#x793A;&#x6BCF;&#x500B;&#x6E2C;&#x8A66; (&#x8A73;&#x7D30;&#x5831;&#x544A;)&#x3002;</li><li><code>pytest -k</code>: &#x9078;&#x64C7;&#x6027;&#x5730;&#x904B;&#x884C;&#x5305;&#x542B;&#x7279;&#x5B9A;&#x95DC;&#x9375;&#x5B57;&#x7684;&#x51FD;&#x6578;&#x6216;&#x65B9;&#x6CD5;&#xFF0C;<code>-k test_func_name</code>&#x6839;&#x64DA;&#x6E2C;&#x8A66;&#x540D;&#x7A31;&#xFF1B;<code>-k my_keyword</code>&#x6839;&#x64DA;&#x95DC;&#x9375;&#x5B57;&#xFF1B;<code>-k keyword1 or keyword2</code>&#x95DC;&#x9375;&#x5B57;&#x8868;&#x9054;&#x5F0F;&#xFF1B;<code>-k &quot;not slow&quot;</code>&#x6392;&#x9664;&#x5305;&#x542B;<strong>slow</strong>&#x95DC;&#x9375;&#x5B57;&#x7684;&#x6E2C;&#x8A66;&#x3002;</li></ol>
<h2 id="%E7%B5%90%E8%AB%96">&#x7D50;&#x8AD6;</h2>
<p>&#x524D;&#x9762;&#x4ECB;&#x7D39;pytest&#x7684;&#x4F7F;&#x7528;&#x65B9;&#x6CD5;&#x57FA;&#x672C;&#x4E0A;&#x5DF2;&#x7D93;&#x80FD;&#x5B8C;&#x6574;&#x7684;&#x6E2C;&#x8A66;&#x4E00;&#x6574;&#x500B;&#x5C08;&#x6848;&#x4E86;&#xFF0C;&#x4E0B;&#x4E00;&#x7BC7;&#x6703;&#x518D;&#x4ECB;&#x7D39;pytest&#x5176;&#x4ED6;&#x5F37;&#x5927;&#x7684;&#x529F;&#x80FD;&#xFF0C;&#x8AF8;&#x5982;fixture&#x3001;conftest&#x3001;coverage&#x3001;&#x7522;&#x751F;&#x5831;&#x8868;&#x7B49;&#x7B49;&#x3002;</p>
<h2 id="%E6%8E%A8%E8%96%A6%E5%8F%83%E8%80%83%E8%B3%87%E6%96%99">&#x63A8;&#x85A6;&#x53C3;&#x8003;&#x8CC7;&#x6599;</h2>
<figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://docs.pytest.org/en/latest/?ref=ghost.augustushsu.com"><div class="kg-bookmark-content"><div class="kg-bookmark-title">pytest: helps you write better programs &#x2014; pytest documentation</div><div class="kg-bookmark-description"></div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://docs.pytest.org/en/latest/_static/favicon.png" alt="Python Note 02"><span class="kg-bookmark-author">Logo</span></div></div><div class="kg-bookmark-thumbnail"><img src="https://docs.pytest.org/en/latest/_static/pytest_logo_curves.svg" alt="Python Note 02"></div></a></figure>
<figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://www.marclittlemore.com/how-to-write-high-quality-unit-tests/?ref=ghost.augustushsu.com"><div class="kg-bookmark-content"><div class="kg-bookmark-title">Crafting High Quality Unit Tests: Tips and Best Practices</div><div class="kg-bookmark-description">Unlock the secrets of high-quality unit testing. Discover how to write effective tests and improve your code quality.</div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://www.marclittlemore.com/favicons/apple-touch-icon.png" alt="Python Note 02"><span class="kg-bookmark-author">Marc Littlemore</span><span class="kg-bookmark-publisher">Marc Littlemore</span></div></div><div class="kg-bookmark-thumbnail"><img src="https://www.marclittlemore.com/images/banners/qualities-of-good-unit-tests.jpg" alt="Python Note 02"></div></a></figure>
<p></p>]]></content:encoded></item><item><title><![CDATA[CI/CD Server Note 05]]></title><description><![CDATA[Drone協助開發團隊更快速地將程式碼部署到生產環境中，同時確保程式碼的品質和穩定性。]]></description><link>https://ghost.augustushsu.com/ci-cd-server-note-05/</link><guid isPermaLink="false">64f9f1a65677df0593b38010</guid><category><![CDATA[CI/CD-Server-Note]]></category><dc:creator><![CDATA[AugustusHsu]]></dc:creator><pubDate>Sun, 08 Oct 2023 12:00:57 GMT</pubDate><media:content url="https://ghost.augustushsu.com/content/images/2023/09/ci-cd-server-note04-2.png" medium="image"/><content:encoded><![CDATA[<h1 id="install-dronecicd-tools">Install Drone - CI/CD Tools</h1>
<img src="https://ghost.augustushsu.com/content/images/2023/09/ci-cd-server-note04-2.png" alt="CI/CD Server Note 05"><p>Drone&#x662F;&#x4E00;&#x500B;&#x4EE5;GO&#x8A9E;&#x8A00;&#x958B;&#x767C;&#x7684;&#x958B;&#x6E90;CI/CD&#x5E73;&#x53F0;&#xFF0C;&#x5B83;&#x53EF;&#x4EE5;&#x5354;&#x52A9;&#x958B;&#x767C;&#x5718;&#x968A;&#x5728;&#x7A0B;&#x5F0F;&#x78BC;&#x8B8A;&#x66F4;&#x6642;&#x81EA;&#x52D5;&#x9032;&#x884C;&#x6E2C;&#x8A66;&#x3001;&#x5EFA;&#x7F6E;&#x548C;&#x90E8;&#x7F72;&#xFF0C;&#x9019;&#x7A2E;&#x81EA;&#x52D5;&#x5316;&#x6D41;&#x7A0B;&#x6709;&#x52A9;&#x65BC;&#x63D0;&#x9AD8;&#x5718;&#x968A;&#x7684;&#x6548;&#x7387;&#xFF0C;&#x78BA;&#x4FDD;&#x7A0B;&#x5F0F;&#x78BC;&#x7684;&#x54C1;&#x8CEA;&#xFF0C;&#x4E26;&#x5FEB;&#x901F;&#x5C07;&#x8B8A;&#x66F4;&#x63A8;&#x9001;&#x5230;&#x751F;&#x7522;&#x74B0;&#x5883;&#x4E2D;&#x3002;</p>
<p>Drone&#x53EF;&#x4EE5;&#x900F;&#x904E;&#x914D;&#x7F6E;&#x7C21;&#x55AE;&#x7684;YAML&#x8A2D;&#x5B9A;&#x6A94;&#x4F86;&#x5B9A;&#x7FA9; CI/CD &#x6D41;&#x7A0B;&#xFF0C;&#x8A72;&#x8A2D;&#x5B9A;&#x6A94;&#x53EF;&#x4EE5;&#x6307;&#x5B9A;&#x54EA;&#x4E9B;&#x6E2C;&#x8A66;&#x9700;&#x8981;&#x904B;&#x884C;&#x3001;&#x4F55;&#x6642;&#x9032;&#x884C;&#x5EFA;&#x7F6E;&#x3001;&#x4EE5;&#x53CA;&#x4F55;&#x6642;&#x5C07;&#x61C9;&#x7528;&#x7A0B;&#x5F0F;&#x90E8;&#x7F72;&#x5230;&#x4F3A;&#x670D;&#x5668;&#x4E0A;&#xFF0C;Drone &#x4E5F;&#x652F;&#x63F4;&#x591A;&#x7A2E;&#x7248;&#x672C;&#x63A7;&#x5236;&#x7CFB;&#x7D71;&#xFF0C;&#x5982;GitHub&#x3001;Gitea&#x548C;GitLab&#x7B49;&#x7B49;&#x3002;</p>
<h2 id="%E5%BB%BA%E7%BD%AE%E8%88%87%E5%AE%89%E8%A3%9Ddrone">&#x5EFA;&#x7F6E;&#x8207;&#x5B89;&#x88DD;Drone</h2>
<p>&#x8981;&#x4F7F;&#x7528;Drone&#x4F86;&#x5EFA;&#x7F6E;CI/CD&#x7684;&#x6D41;&#x7A0B;&#x9700;&#x8981;&#x5148;&#x5EFA;&#x7ACB;&#x7248;&#x672C;&#x63A7;&#x5236;&#x7CFB;&#x7D71;&#xFF0C;&#x6839;&#x64DA;<a href="https://docs.drone.io/server/overview/?ref=ghost.augustushsu.com">Drone&#x7684;&#x6587;&#x6A94;&#x7DB2;&#x7AD9;</a>&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x6240;&#x652F;&#x63F4;&#x7684;&#x7248;&#x672C;&#x63A7;&#x5236;&#x7CFB;&#x7D71;&#xFF0C;&#x5728;<a href="https://ghost.augustushsu.com/cicd-server-record-note01/">&#x5148;&#x524D;&#x7684;&#x6587;&#x7AE0;</a>&#x4ECB;&#x7D39;&#x4E86;&#x5982;&#x4F55;&#x5B89;&#x88DD;Gitea&#xFF0C;&#x5B89;&#x88DD;&#x597D;&#x4E86;Gitea&#x4E4B;&#x5F8C;&#x9700;&#x8981;&#x5728;Gitea&#x7684;&#x8A2D;&#x5B9A;&#x6388;&#x6B0A;OAuth2&#x624D;&#x53EF;&#x4EE5;&#x958B;&#x59CB;&#x5B89;&#x88DD;Drone&#x3002;</p>
<p>&#x5728;Gitea &gt; &#x8A2D;&#x5B9A; &gt; &#x61C9;&#x7528;&#x7A0B;&#x5F0F; &gt; &#x65B0;&#x589E;OAuth2&#x61C9;&#x7528;&#x7A0B;&#x5F0F;&#x5BEB;&#x5165;&#x9700;&#x8981;&#x7684;&#x8CC7;&#x8A0A;&#xFF0C;&#x5176;&#x4E2D;&#x4E0B;&#x9762;&#x90A3;&#x9805;URL&#x6839;&#x64DA;&#x4F60;&#x4E4B;&#x5F8C;&#x8981;&#x5EFA;&#x7ACB;&#x7684;Drone&#x7DB2;&#x5740;&#x586B;&#x5165;&#x5373;&#x53EF;&#xFF0C;&#x82E5;&#x9084;&#x4E0D;&#x6E05;&#x695A;&#x5F8C;&#x7E8C;&#x518D;&#x505A;&#x66F4;&#x6539;&#x4E5F;&#x53EF;&#x4EE5;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/08/image-20.png" class="kg-image" alt="CI/CD Server Note 05" loading="lazy" width="943" height="645" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/08/image-20.png 600w, https://ghost.augustushsu.com/content/images/2023/08/image-20.png 943w" sizes="(min-width: 720px) 720px"></figure>
<p>&#x5EFA;&#x7ACB;&#x61C9;&#x7528;&#x7A0B;&#x5F0F;&#x5F8C;&#x8981;&#x8A18;&#x9304;&#x5BA2;&#x6236;&#x7AEF;ID&#x548C;&#x5BA2;&#x6236;&#x7AEF;&#x5BC6;&#x9470;&#xFF0C;&#x5728;&#x5F8C;&#x7E8C;&#x5B89;&#x88DD;Drone&#x7684;&#x6642;&#x5019;&#x6703;&#x7528;&#x5230;&#xFF0C;&#x5BC6;&#x9470;&#x5728;&#x6309;&#x4E0B;&#x5132;&#x5B58;&#x6309;&#x9215;&#x5F8C;&#x6703;&#x88AB;&#x96B1;&#x85CF;&#xFF0C;&#x82E5;&#x5F8C;&#x9762;&#x5FD8;&#x8A18;&#x7684;&#x8A71;&#x4E5F;&#x6C92;&#x95DC;&#x4FC2;&#xFF0C;&#x6309;&#x4E0B;&#x91CD;&#x65B0;&#x7522;&#x751F;&#x5BC6;&#x9470;&#x5C31;&#x53EF;&#x4EE5;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/08/Screenshot-2023-08-29-213117.png" class="kg-image" alt="CI/CD Server Note 05" loading="lazy" width="950" height="1056" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/08/Screenshot-2023-08-29-213117.png 600w, https://ghost.augustushsu.com/content/images/2023/08/Screenshot-2023-08-29-213117.png 950w" sizes="(min-width: 720px) 720px"></figure>
<p>&#x5F8C;&#x7E8C;&#x56E0;&#x70BA;&#x8981;&#x5EFA;&#x7F6E;drone-runner&#xFF0C;&#x9700;&#x8981;&#x900F;&#x904E;OpenSSL&#x751F;&#x6210;&#x4E00;&#x7D44;&#x5BC6;&#x9470;&#x3002;&#x900F;&#x904E;&#x4E0B;&#x9762;&#x6307;&#x4EE4;&#x5728;linux&#x7522;&#x751F;&#x4E00;&#x7D44;&#x9577;&#x5EA6;&#x70BA;128 &#x500B;&#x4F4D;&#x5143;&#x7D44;(16 &#x500B;&#x5B57;&#x5143;)&#x96A8;&#x6A5F;(rand&#x5B50;&#x6307;&#x4EE4;)&#x7684;&#x5341;&#x516D;&#x9032;&#x5236;&#x5B57;&#x4E32;&#xFF0C;&#x52A0;&#x4E0A;&quot;-hex&quot;&#x9078;&#x9805;&#xFF0C;&#x8868;&#x793A;&#x8981;&#x8F38;&#x51FA;&#x5341;&#x516D;&#x9032;&#x5236;&#x5F62;&#x5F0F;&#x7684;&#x96A8;&#x6A5F;&#x6578;:</p>
<pre><code class="language-sh">openssl rand -hex 16</code></pre>
<p>&#x63A5;&#x4E0B;&#x4F86;&#x5C31;&#x53EA;&#x5269;&#x4E0B;&#x5EFA;&#x7ACB;Drone Server&#x548C;Drone Runner&#x7684;Docker&#xFF0C;&#x5C07;&#x524D;&#x9762;&#x6240;&#x8A18;&#x9304;&#x7684;&#x5BA2;&#x6236;&#x7AEF;ID&#x3001;&#x5BA2;&#x6236;&#x7AEF;&#x5BC6;&#x9470;&#x548C;&#x900F;&#x904E;OpenSSL&#x7522;&#x751F;&#x7684;&#x96A8;&#x6A5F;&#x6578;&#x586B;&#x5165;&#x4E0B;&#x9762;&#x7684;docker-compose.yml&#x4E0A;&#xFF0C;&#x7528;docker-compose&#x5EFA;&#x7ACB;:</p>
<pre><code class="language-yaml">version: &quot;3&quot;

services:
  drone-server:
    image: drone/drone:latest
    container_name: drone-server
    ports:
      - &quot;5080:80&quot;
    volumes:
      - ./drone:/data
      - /var/run/docker.sock:/var/run/docker.sock
    restart: always
    environment:
      - DRONE_GITEA_SERVER=your.gitea.website
      - DRONE_GITEA_CLIENT_SECRET=&#x5BA2;&#x6236;&#x7AEF;&#x5BC6;&#x9470;
      - DRONE_GITEA_CLIENT_ID=&#x5BA2;&#x6236;&#x7AEF;ID
      - DRONE_GIT_ALWAYS_AUTH=true
      - DRONE_SERVER_HOST=your.drone.website
      - DRONE_SERVER_PROTO=http
      - DRONE_RPC_SECRET=&#x900F;&#x904E;OpenSSL&#x7522;&#x751F;&#x7684;&#x96A8;&#x6A5F;&#x6578;
      - DRONE_AGENTS_ENABLED=true
      # &#x5148;&#x81EA;&#x884C;&#x5EFA;&#x7ACB;admin
      - DRONE_USER_CREATE=username:your_user_name,admin:true
      - DRONE_UI_USERNAME=root
      - DRONE_UI_PASSWORD=root

  drone-agent:
    image: drone/drone-runner-docker:latest
    container_name: drone-runner
    ports:
      - &quot;30001:3000&quot;
    restart: always
    depends_on:
      - drone-server
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      - DRONE_RPC_PROTO=http
      - DRONE_RPC_HOST=your.drone.website
      - DRONE_RPC_SECRET=&#x900F;&#x904E;OpenSSL&#x7522;&#x751F;&#x7684;&#x96A8;&#x6A5F;&#x6578;
      - DRONE_RUNNER_CAPACITY=10
      - DRONE_RUNNER_NAME=agent-01</code></pre>
<h2 id="%E4%BD%BF%E7%94%A8drone%E5%85%A5%E9%96%80">&#x4F7F;&#x7528;Drone - &#x5165;&#x9580;</h2>
<p>&#x5EFA;&#x597D;&#x5F8C;Server&#x8DDF;Runner&#x5F8C;&#x958B;&#x555F;&#x4E00;&#x500B;&#x5C08;&#x6848;&#xFF0C;&#x7DE8;&#x8F2F;<code>.drone.yml</code>&#x8F38;&#x5165;&#x4EE5;&#x4E0B;&#x7A0B;&#x5F0F;&#x78BC;&#xFF0C;&#x9001;&#x51FA;commit&#x5F8C;push&#x5230;Gitea:</p>
<pre><code class="language-yaml">kind: pipeline
type: docker
name: hello_world

steps:
- name: hello_world
  image: ubuntu:20.04
  commands:
    - echo hello drone</code></pre>
<p>&#x9032;&#x5165;Drone Server&#x7684;&#x7DB2;&#x5740;&#xFF0C;&#x9EDE;&#x9078;CONTINUE:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/09/image-29.png" class="kg-image" alt="CI/CD Server Note 05" loading="lazy" width="1781" height="780" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/09/image-29.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2023/09/image-29.png 1000w, https://ghost.augustushsu.com/content/images/size/w1600/2023/09/image-29.png 1600w, https://ghost.augustushsu.com/content/images/2023/09/image-29.png 1781w" sizes="(min-width: 720px) 720px"></figure>
<p>&#x63A5;&#x4E0B;&#x4F86;&#x6703;&#x9700;&#x8981;&#x586B;&#x5165;&#x4F60;&#x7684;&#x57FA;&#x672C;&#x8A0A;&#x606F;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/09/image-41.png" class="kg-image" alt="CI/CD Server Note 05" loading="lazy" width="409" height="630"></figure>
<p>&#x6388;&#x6B0A;Drone&#x53EF;&#x4EE5;&#x5B58;&#x53D6;&#x4F60;&#x7684;&#x5E33;&#x6236;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/09/image-30.png" class="kg-image" alt="CI/CD Server Note 05" loading="lazy" width="567" height="426"></figure>
<p>&#x8655;&#x7406;&#x5B8C;&#x5F8C;&#x5C31;&#x53EF;&#x4EE5;&#x770B;&#x5230;Drone&#x7684;&#x7BA1;&#x7406;&#x9801;&#x9762;&#xFF0C;&#x5728;&#x9996;&#x9801;&#x6703;&#x986F;&#x793A;&#x53EF;&#x4EE5;&#x5B58;&#x53D6;&#x5230;&#x7684;&#x6240;&#x6709;&#x5C08;&#x6848;&#xFF0C;&#x5982;&#x679C;&#x6C92;&#x6709;&#x986F;&#x793A;&#x53EF;&#x4EE5;&#x9EDE;&#x64CA;SYNC&#x5230;Drone&#xFF0C;&#x9019;&#x500B;&#x6642;&#x5019;Drone&#x9084;&#x4E0D;&#x6703;&#x958B;&#x59CB;&#x5DE5;&#x4F5C;&#xFF0C;&#x9700;&#x8981;&#x555F;&#x7528;&#x8981;&#x4F7F;&#x7528;Drone&#x7684;&#x5C08;&#x6848;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/09/image-32.png" class="kg-image" alt="CI/CD Server Note 05" loading="lazy" width="1320" height="595" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/09/image-32.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2023/09/image-32.png 1000w, https://ghost.augustushsu.com/content/images/2023/09/image-32.png 1320w" sizes="(min-width: 720px) 720px"></figure>
<p>&#x9032;&#x5165;&#x525B;&#x525B;&#x5EFA;&#x7ACB;&#x7684;&#x5C08;&#x6848;&#x5F8C;&#xFF0C;&#x9EDE;&#x9078;&#x756B;&#x9762;&#x4E2D;&#x592E;&#x7684;+ACTIVATE REPOSITORY &#x5C31;&#x53EF;&#x4EE5;&#x70BA;&#x9019;&#x500B;&#x5C08;&#x6848;&#x555F;&#x7528;&#x3001;&#x5EFA;&#x7ACB;CI&#x7684;&#x6D41;&#x7A0B;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/09/image-33.png" class="kg-image" alt="CI/CD Server Note 05" loading="lazy" width="1281" height="820" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/09/image-33.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2023/09/image-33.png 1000w, https://ghost.augustushsu.com/content/images/2023/09/image-33.png 1281w" sizes="(min-width: 720px) 720px"></figure>
<p>&#x555F;&#x7528;&#x5F8C;Settings&#x7684;&#x9801;&#x9762;&#x6703;&#x9577;&#x9019;&#x6A23;&#xFF0C;&#x5F8C;&#x7E8C;&#x5982;&#x679C;&#x9700;&#x8981;&#x505A;&#x4E00;&#x4E9B;&#x8ABF;&#x6574;&#x6216;&#x662F;&#x6DFB;&#x52A0;&#x4E00;&#x4E9B;&#x53C3;&#x6578;&#x53EF;&#x4EE5;&#x5728;&#x9019;&#x500B;&#x9801;&#x9762;&#x4E2D;&#x8ABF;&#x6574;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/09/image-36.png" class="kg-image" alt="CI/CD Server Note 05" loading="lazy" width="1557" height="766" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/09/image-36.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2023/09/image-36.png 1000w, https://ghost.augustushsu.com/content/images/2023/09/image-36.png 1557w" sizes="(min-width: 720px) 720px"></figure>
<p>&#x9EDE;&#x9078;Builds&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x525B;&#x525B;push&#x4E0A;&#x53BB;&#x7684;commit&#x5DF2;&#x7D93;&#x901A;&#x904E;&#x6E2C;&#x8A66;&#x4E86;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/09/image-38.png" class="kg-image" alt="CI/CD Server Note 05" loading="lazy" width="1518" height="872" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/09/image-38.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2023/09/image-38.png 1000w, https://ghost.augustushsu.com/content/images/2023/09/image-38.png 1518w" sizes="(min-width: 720px) 720px"></figure>
<p>&#x9EDE;&#x9032;&#x9019;&#x6B21;&#x7684;&#x7D00;&#x9304;&#x4E4B;&#x5F8C;&#xFF0C;&#x5C31;&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x95DC;&#x65BC;&#x9019;&#x6B21; Build &#x7684;&#x8A73;&#x7D30;&#x904E;&#x7A0B;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/09/image-39.png" class="kg-image" alt="CI/CD Server Note 05" loading="lazy" width="1535" height="874" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/09/image-39.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2023/09/image-39.png 1000w, https://ghost.augustushsu.com/content/images/2023/09/image-39.png 1535w" sizes="(min-width: 720px) 720px"></figure>
<p>&#x5728;Gitea&#x4E0A;&#x53EF;&#x4EE5;&#x5728;Commit Message&#x5F8C;&#x9762;&#x770B;&#x5230;&#x4E00;&#x500B;&#x2705;&#xFF0C;&#x4EE3;&#x8868;&#x901A;&#x904E;&#x4E86;&#x4F60;&#x5BEB;&#x7684;&#x6E2C;&#x8A66;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/09/image-40.png" class="kg-image" alt="CI/CD Server Note 05" loading="lazy" width="1396" height="594" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/09/image-40.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2023/09/image-40.png 1000w, https://ghost.augustushsu.com/content/images/2023/09/image-40.png 1396w" sizes="(min-width: 720px) 720px"></figure>
<h2 id="%E7%B5%90%E8%AB%96">&#x7D50;&#x8AD6;</h2>
<p>&#x7E3D;&#x7D50;&#x4F86;&#x8AAA;&#xFF0C;Drone&#x662F;&#x4E00;&#x500B;&#x7528;&#x65BC;&#x81EA;&#x52D5;&#x5316;&#x6301;&#x7E8C;&#x6574;&#x5408;&#x548C;&#x6301;&#x7E8C;&#x4EA4;&#x4ED8;&#x6D41;&#x7A0B;&#x7684;&#x5DE5;&#x5177;&#xFF0C;&#x5B83;&#x53EF;&#x4EE5;&#x5354;&#x52A9;&#x958B;&#x767C;&#x5718;&#x968A;&#x66F4;&#x5FEB;&#x901F;&#x5730;&#x5C07;&#x7A0B;&#x5F0F;&#x78BC;&#x90E8;&#x7F72;&#x5230;&#x751F;&#x7522;&#x74B0;&#x5883;&#x4E2D;&#xFF0C;&#x540C;&#x6642;&#x78BA;&#x4FDD;&#x7A0B;&#x5F0F;&#x78BC;&#x7684;&#x54C1;&#x8CEA;&#x548C;&#x7A69;&#x5B9A;&#x6027;&#x3002;</p>
<p></p>
<p></p>]]></content:encoded></item><item><title><![CDATA[CI/CD Server Note 04]]></title><description><![CDATA[<h1 id="pre-commit%E7%A8%8B%E5%BC%8F%E7%A2%BC%E9%A2%A8%E6%A0%BC%E6%AA%A2%E6%9F%A5">pre-commit&#x7A0B;&#x5F0F;&#x78BC;&#x98A8;&#x683C;&#x6AA2;&#x67E5;</h1>
<p>&#x5728;&#x591A;&#x4EBA;&#x5354;&#x4F5C;&#x958B;&#x767C;&#x8EDF;&#x9AD4;&#x7684;&#x60C5;&#x5883;&#x4E0B;&#xFF0C;&#x7A0B;&#x5F0F;&#x78BC;&#x54C1;&#x8CEA;&#x662F;&#x4E00;&#x500B;&#x9700;&#x8981;&#x91CD;&#x8996;&#x7684;&#x8B70;&#x984C;&#xFF0C;&#x8981;&#x78BA;&#x4FDD;&#x7A0B;&#x5F0F;&#x78BC;&#x7684;&#x4E00;&#x81F4;&#x6027;&#x3001;&#x53EF;</p>]]></description><link>https://ghost.augustushsu.com/ci-cd-server-note-04/</link><guid isPermaLink="false">650490125677df0593b388a8</guid><category><![CDATA[CI/CD-Server-Note]]></category><dc:creator><![CDATA[AugustusHsu]]></dc:creator><pubDate>Sun, 01 Oct 2023 12:00:17 GMT</pubDate><media:content url="https://ghost.augustushsu.com/content/images/2023/09/ci-cd-server-note-04-3.png" medium="image"/><content:encoded><![CDATA[<h1 id="pre-commit%E7%A8%8B%E5%BC%8F%E7%A2%BC%E9%A2%A8%E6%A0%BC%E6%AA%A2%E6%9F%A5">pre-commit&#x7A0B;&#x5F0F;&#x78BC;&#x98A8;&#x683C;&#x6AA2;&#x67E5;</h1>
<img src="https://ghost.augustushsu.com/content/images/2023/09/ci-cd-server-note-04-3.png" alt="CI/CD Server Note 04"><p>&#x5728;&#x591A;&#x4EBA;&#x5354;&#x4F5C;&#x958B;&#x767C;&#x8EDF;&#x9AD4;&#x7684;&#x60C5;&#x5883;&#x4E0B;&#xFF0C;&#x7A0B;&#x5F0F;&#x78BC;&#x54C1;&#x8CEA;&#x662F;&#x4E00;&#x500B;&#x9700;&#x8981;&#x91CD;&#x8996;&#x7684;&#x8B70;&#x984C;&#xFF0C;&#x8981;&#x78BA;&#x4FDD;&#x7A0B;&#x5F0F;&#x78BC;&#x7684;&#x4E00;&#x81F4;&#x6027;&#x3001;&#x53EF;&#x8B80;&#x6027;&#x548C;&#x53EF;&#x7DAD;&#x8B77;&#x6027;&#xFF0C;&#x9664;&#x4E86;&#x7A0B;&#x5F0F;&#x78BC;&#x91CD;&#x69CB;&#xFF0C;&#x9084;&#x6709;&#x4E00;&#x500B;&#x6975;&#x70BA;&#x5BE6;&#x7528;&#x7684;&#x5DE5;&#x5177;&#xFF0C;&#x90A3;&#x5C31;&#x662F;<code>pre-commit</code>&#x3002;</p>
<p>&#x9019;&#x500B;&#x5DE5;&#x5177;&#x53EF;&#x4EE5;&#x5728;&#x7A0B;&#x5F0F;&#x78BC;&#x63D0;&#x4EA4;&#x4E4B;&#x524D;&#x81EA;&#x52D5;&#x57F7;&#x884C;&#x7A0B;&#x5F0F;&#x78BC;&#x683C;&#x5F0F;&#x5316;&#x3001;&#x8A9E;&#x6CD5;&#x6AA2;&#x67E5;&#x7B49;&#x7B49;&#xFF0C;&#x78BA;&#x4FDD;&#x5728;&#x7A0B;&#x5F0F;&#x78BC;&#x9032;&#x5165;&#x7248;&#x672C;&#x63A7;&#x5236;&#x7CFB;&#x7D71;&#x4E4B;&#x524D;&#x7B26;&#x5408;&#x4E00;&#x5B9A;&#x7684;&#x54C1;&#x8CEA;&#x6A19;&#x6E96;&#x548C;&#x898F;&#x7BC4;&#xFF0C;&#x6709;&#x52A9;&#x65BC;&#x9632;&#x6B62;&#x4E0D;&#x826F;&#x7A0B;&#x5F0F;&#x78BC;&#x9032;&#x5165;&#x7248;&#x672C;&#x63A7;&#x5236;&#x7CFB;&#x7D71;&#xFF0C;&#x6E1B;&#x5C11;&#x5728;&#x5F8C;&#x7E8C;&#x7684;CI/CD pipeline&#x904E;&#x7A0B;&#x767C;&#x751F;&#x932F;&#x8AA4;&#x800C;&#x9700;&#x8981;&#x505A;code review&#x7684;&#x6B21;&#x6578;&#xFF0C;&#x5F9E;&#x800C;&#x63D0;&#x5347;&#x6574;&#x500B;&#x5718;&#x968A;&#x7684;&#x6548;&#x7387;&#x548C;&#x7A0B;&#x5F0F;&#x78BC;&#x7684;&#x54C1;&#x8CEA;&#x548C;&#x6548;&#x7387;&#x3002;</p>
<h2 id="hooks">Hooks</h2>
<p><code>pre-commit</code>&#x662F;&#x900F;&#x904E;Git&#x7684;Git Hooks&#x4F86;&#x5BE6;&#x73FE;&#x7684;&#xFF0C;&#x7576;&#x67D0;&#x4E9B;&#x64CD;&#x4F5C;git&#x7684;&#x52D5;&#x4F5C;&#x767C;&#x751F;&#x6642;&#xFF0C;&#x6703;&#x89F8;&#x767C;&#x81EA;&#x5B9A;&#x7FA9;&#x7684;script&#xFF0C;&#x800C;<code>pre-commit</code>&#x5982;&#x540C;&#x5B57;&#x9762;&#x4E0A;&#x7684;&#x610F;&#x601D;&#xFF0C;&#x662F;&#x5728;commit&#x7684;&#x6642;&#x5019;&#x6703;&#x5148;&#x89F8;&#x767C;&#x5B9A;&#x7FA9;&#x7684;script&#x5C0D;&#x7A0B;&#x5F0F;&#x78BC;&#x9032;&#x884C;&#x6AA2;&#x67E5;&#x6216;&#x662F;&#x5176;&#x4ED6;&#x64CD;&#x4F5C;&#xFF0C;&#x518D;&#x9032;&#x884C;commit&#x7684;&#x52D5;&#x4F5C;&#x3002;</p>
<p>Hooks&#x5927;&#x81F4;&#x4E0A;&#x53EF;&#x5206;&#x6210;<code>pre-</code>&#x8DDF;<code>post-</code>&#x5169;&#x7A2E;&#xFF0C;&#x9664;&#x4E86;&#x9019;&#x5169;&#x7A2E;&#x4EE5;&#x5916;&#x5E38;&#x7528;&#x7684;&#x9084;&#x6709;<code>commit-msg</code>&#x8DDF;<code>update</code>:</p>
<ul><li><code>pre-</code> : &#x4EE3;&#x8868;&#x5728;Git&#x64CD;&#x4F5C;&#x57F7;&#x884C;&#x4E4B;&#x524D;&#x6240;&#x8981;&#x9032;&#x884C;&#x7684;&#x52D5;&#x4F5C;&#xFF0C;&#x53EF;&#x4EE5;&#x7528;&#x4F86;&#x505A;&#x57F7;&#x884C;&#x4EE3;&#x78BC;&#x98A8;&#x683C;&#x6AA2;&#x67E5;&#x3001;&#x6E2C;&#x8A66;&#x3001;&#x9A57;&#x8B49;&#x63D0;&#x4EA4;&#x5167;&#x5BB9;&#x7B49;&#x64CD;&#x4F5C;&#x3002;</li><li><code>post-</code> : &#x5247;&#x5728;Git&#x64CD;&#x4F5C;&#x57F7;&#x884C;&#x4E4B;&#x5F8C;&#x8981;&#x9032;&#x884C;&#x7684;&#x52D5;&#x4F5C;&#xFF0C;&#x901A;&#x5E38;&#x7528;&#x4F86;&#x57F7;&#x884C;&#x81EA;&#x52D5;&#x5316;&#x90E8;&#x7F72;&#x3001;&#x767C;&#x9001;&#x901A;&#x77E5;&#x6216;&#x65E5;&#x8A8C;&#x8A18;&#x9304;&#x7B49;&#x5F8C;&#x8655;&#x7406;&#x64CD;&#x4F5C;&#x3002;</li><li><code>commit-msg</code> : &#x5728;&#x63D0;&#x4EA4;&#x8A0A;&#x606F;(commit message)&#x88AB;&#x7DE8;&#x8F2F;&#x5F8C;&#x89F8;&#x767C;&#xFF0C;&#x53EF;&#x7528;&#x65BC;&#x6AA2;&#x67E5;&#x63D0;&#x4EA4;&#x8A0A;&#x606F;&#x7684;&#x683C;&#x5F0F;&#x3002;</li><li><code>update</code> : &#x5728;&#x53C3;&#x8003;(reference)&#x66F4;&#x65B0;&#x6642;&#x89F8;&#x767C;&#xFF0C;&#x53EF;&#x7528;&#x65BC;&#x9A57;&#x8B49;&#x53C3;&#x8003;&#x7684;&#x66F4;&#x65B0;&#x3002;</li></ul>
<p>&#x901A;&#x5E38;&#x60C5;&#x6CC1;&#x4E0B;&#xFF0C;&#x9019;&#x4E9B;hook script&#x901A;&#x5E38;&#x9700;&#x8981;&#x642D;&#x914D;&#x7279;&#x5B9A;&#x7684;&#x6A94;&#x6848;&#x3001;&#x5DE5;&#x5177;&#x548C;&#x57F7;&#x884C;&#x74B0;&#x5883;&#xFF0C;&#x4EE5;&#x5BE6;&#x73FE;&#x5176;&#x529F;&#x80FD;&#xFF0C;&#x56E0;&#x6B64;&#x6574;&#x5305;&#x53EF;&#x80FD;&#x6703;&#x8B8A;&#x5F97;&#x76F8;&#x7576;&#x9F90;&#x5927;&#x3002;&#x7576;&#x9700;&#x8981;&#x5728;&#x5176;&#x4ED6;&#x5C08;&#x6848;&#x4E2D;&#x4F7F;&#x7528;&#x9019;&#x500B;hook script&#x6642;&#x5FC5;&#x9808;&#x5C07;&#x9019;&#x9F90;&#x5927;&#x7684;script&#x8907;&#x88FD;&#x5230;&#x53E6;&#x500B;&#x5C08;&#x6848;&#x4E2D;&#xFF0C;&#x9019;&#x500B;&#x904E;&#x7A0B;&#x975E;&#x5E38;&#x9EBB;&#x7169;&#xFF0C;&#x800C;<code>pre-commit</code>&#x5957;&#x4EF6;&#x5C31;&#x662F;&#x70BA;&#x4E86;&#x89E3;&#x6C7A;&#x9019;&#x500B;&#x554F;&#x984C;&#x3002;</p>
<h2 id="pre-commit%E5%9F%BA%E6%9C%AC%E8%A8%AD%E5%AE%9A">pre-commit&#x57FA;&#x672C;&#x8A2D;&#x5B9A;</h2>
<p><code>pre-commit</code>&#x6700;&#x521D;&#x662F;&#x70BA;&#x4E86;Python&#x8A2D;&#x8A08;&#x7684;&#x5957;&#x4EF6;&#xFF0C;&#x4E0D;&#x904E;&#x4E5F;&#x53EF;&#x4EE5;&#x7528;&#x65BC;&#x5176;&#x4ED6;&#x8A9E;&#x8A00;&#x7684;&#x9805;&#x76EE;&#xFF0C;&#x53EA;&#x8981;&#x8A2D;&#x8A08;&#x597D;&#x8981;&#x4F7F;&#x7528;&#x7684;&#x8A9E;&#x8A00;&#x76F8;&#x61C9;&#x7684;&#x6AA2;&#x67E5;&#x3001;&#x9A57;&#x8B49;&#x8173;&#x672C;&#x3002;&#x76EE;&#x524D;&#x5C08;&#x6848;&#x4E2D;&#x6211;&#x90FD;&#x4F7F;&#x7528;Poetry&#x4F86;&#x7BA1;&#x7406;python&#x7684;&#x5957;&#x4EF6;&#xFF0C;&#x6240;&#x4EE5;&#x9019;&#x88E1;&#x4F7F;&#x7528;poetry&#x4F86;&#x5B89;&#x88DD;<code>pre-commit</code>&#xFF0C;&#x4F7F;&#x7528;pip&#x4F86;&#x5B89;&#x88DD;&#x4E5F;&#x53EF;&#x4EE5;&#xFF0C;&#x7531;&#x65BC;<code>pre-commit</code>&#x5E0C;&#x671B;&#x53EA;&#x5728;&#x958B;&#x767C;&#x74B0;&#x5883;&#x4F7F;&#x7528;&#xFF0C;&#x4E0D;&#x6703;&#x60F3;&#x8981;&#x5728;&#x6E2C;&#x8A66;&#x6216;&#x662F;&#x7522;&#x54C1;&#x4E0A;&#x5B89;&#x88DD;&#x4ED6;&#xFF0C;&#x6240;&#x4EE5;&#x8981;&#x8A2D;&#x5B9A;&#x6210;<code>--group main</code>:</p>
<pre><code class="language-bash">poetry add pre-commit --group main
pip install pre-commit</code></pre>
<h3 id="%E8%A8%AD%E5%AE%9A%E6%AA%94">&#x8A2D;&#x5B9A;&#x6A94;</h3>
<p>&#x63A5;&#x4E0B;&#x4F86;&#x8981;&#x5728;&#x5C08;&#x6848;&#x7684;&#x6839;&#x76EE;&#x9304;&#x5275;&#x5EFA;<code>.pre-commit-config.yaml</code>&#x6A94;&#x6848;&#x7BC4;&#x4F8B;&#x5982;&#x4E0B;:</p>
<pre><code class="language-yaml">repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.4.0
    hooks:
      - id: trailing-whitespace
      - id: check-added-large-files
      - id: check-ast
      - id: check-case-conflict
      - id: check-json
      - id: check-toml
      - id: check-yaml
      - id: end-of-file-fixer
      
  - repo: # &#x5F8C;&#x7565;
</code></pre>
<p>&#x5176;&#x4E2D;yaml&#x6A94;&#x6848;&#x7684;<code>repo</code>&#x3001;<code>rev</code>&#x3001;<code>hooks</code>&#x3001;<code>id</code>&#x4EE5;&#x5916;&#x9084;&#x6709;&#x5176;&#x4ED6;&#x53EF;&#x6DFB;&#x52A0;&#x7684;&#x5143;&#x7D20;&#xFF0C;&#x6240;&#x4EE3;&#x8868;&#x7684;&#x610F;&#x7FA9;&#x70BA;&#x4F55;&#x53EF;&#x4EE5;&#x53C3;&#x8003;&#x5B98;&#x65B9;&#x7684;<a href="https://pre-commit.com/?ref=ghost.augustushsu.com#adding-pre-commit-plugins-to-your-project">&#x6587;&#x6A94;</a>&#xFF0C;&#x4E0B;&#x9762;&#x4ECB;&#x7D39;&#x7BC4;&#x4F8B;&#x4E2D;&#x4F7F;&#x7528;&#x5230;&#x7684;&#x5143;&#x7D20;:</p>
<ul><li><code>repo</code> : &#x53EF;&#x4EE5;&#x7528;<code>git clone</code>&#x7684;repository&#x9023;&#x7D50;&#x3002;</li><li><code>rev</code> : rev&#x70BA;&#x5C0D;&#x61C9;&#x7684;&#x7248;&#x672C;&#x865F;&#xFF0C;&#x53EF;&#x4EE5;&#x5728;release&#x7684;<a href="https://github.com/pre-commit/pre-commit-hooks/tags?ref=ghost.augustushsu.com">tag&#x9801;&#x9762;</a>&#x770B;&#x5230;&#x3002;</li><li><code>hooks</code> : &#x8981;&#x4F7F;&#x7528;&#x54EA;&#x4E9B;hook&#xFF0C;&#x9019;&#x500B;<a href="https://pre-commit.com/?ref=ghost.augustushsu.com#pre-commit-configyaml---hooks">&#x9801;&#x9762;</a>&#x5217;&#x51FA;&#x4E86;&#x53EF;&#x4F7F;&#x7528;&#x7684;&#x8B8A;&#x6578;&#x3002;</li><li><code>id</code> : &#x8981;&#x4F7F;&#x7528;&#x5B58;&#x5132;&#x5EAB;&#x4E2D;&#x7684;&#x54EA;&#x500B;hook&#x3002;</li></ul>
<p>&#x4E0A;&#x9762;&#x9019;&#x500B;&#x7BC4;&#x4F8B;&#x4F7F;&#x7528;&#x7684;&#x662F;&#x7531;<code>pre-commit</code>&#x63D0;&#x4F9B;&#x7684;&#x57FA;&#x672C;hooks:</p>
<ul><li><code>trailing-whitespace</code> : &#x6AA2;&#x67E5;&#x7A0B;&#x5F0F;&#x78BC;&#x662F;&#x5426;&#x5B58;&#x5728;&#x591A;&#x9918;&#x7684;&#x5C3E;&#x96A8;&#x7A7A;&#x683C;&#x3002;</li><li><code>check-added-large-files</code> : &#x6AA2;&#x67E5;&#x662F;&#x5426;&#x6DFB;&#x52A0;&#x4E86;&#x904E;&#x5927;&#x7684;&#x6587;&#x4EF6;&#x3002;</li><li><code>check-ast</code> : &#x5C0D;&#x7A0B;&#x5F0F;&#x78BC;&#x9032;&#x884C;<strong>&#x62BD;&#x8C61;&#x8A9E;&#x6CD5;&#x6A39;(AST)</strong>&#x5206;&#x6790;&#xFF0C;&#x4EE5;&#x6AA2;&#x67E5;&#x6DFA;&#x5728;&#x7684;&#x554F;&#x984C;&#x3002;</li><li><code>check-case-conflict</code> : &#x6AA2;&#x67E5;&#x6A94;&#x6848;&#x540D;&#x7684;&#x5927;&#x5C0F;&#x5BEB;&#x662F;&#x5426;&#x8207;&#x7248;&#x672C;&#x63A7;&#x5236;&#x7CFB;&#x7D71;&#x4E2D;&#x7684;&#x6587;&#x4EF6;&#x885D;&#x7A81;&#x3002;</li><li><code>check-json</code> : &#x9A57;&#x8B49;JSON&#x6587;&#x4EF6;&#x7684;&#x683C;&#x5F0F;&#x662F;&#x5426;&#x6B63;&#x78BA;&#x3002;</li><li><code>check-toml</code> : &#x9A57;&#x8B49;TOML&#x6587;&#x4EF6;&#x7684;&#x683C;&#x5F0F;&#x662F;&#x5426;&#x6B63;&#x78BA;&#x3002;</li><li><code>check-yaml</code> : &#x9A57;&#x8B49;YAML&#x6587;&#x4EF6;&#x7684;&#x683C;&#x5F0F;&#x662F;&#x5426;&#x6B63;&#x78BA;&#x3002;</li><li><code>end-of-file-fixer</code> : &#x81EA;&#x52D5;&#x6DFB;&#x52A0;&#x6587;&#x4EF6;&#x672B;&#x5C3E;&#x7684;&#x63DB;&#x884C;&#x7B26;&#x865F;&#x3002;</li></ul>
<p>&#x200B;&#x4EE5;&#x4E0A;&#x662F;&#x5217;&#x51FA;<code>pre-commit-hooks</code>&#x81EA;&#x5E36;&#x7684;&#x4E00;&#x4E9B;&#x5E38;&#x7528;hook&#xFF0C;&#x5982;&#x679C;&#x6709;&#x9700;&#x8981;&#x6DFB;&#x52A0;&#x65B0;&#x7684;hook&#x53EF;&#x4EE5;&#x53BB;<a href="https://pre-commit.com/hooks.html?ref=ghost.augustushsu.com"><strong>&#x5B98;&#x65B9;&#x6587;&#x6A94;</strong></a>&#x4E2D;&#x5C0B;&#x627E;&#x3002;</p>
<h3 id="%E4%BD%BF%E7%94%A8">&#x4F7F;&#x7528;</h3>
<p>&#x5728;&#x4E0B;&#x6307;&#x4EE4;&#x4EE5;&#x524D;&#x8981;&#x78BA;&#x5B9A;&#x5DF2;&#x7D93;&#x9032;&#x5165;&#x4E86;&#x5B89;&#x88DD;&#x4E86;<code>pre-commit</code>&#x7684;python&#x865B;&#x64EC;&#x74B0;&#x5883;&#xFF0C;&#x4E0D;&#x7136;&#x53EF;&#x80FD;&#x6703;&#x627E;&#x4E0D;&#x5230;&#x6307;&#x4EE4;&#xFF0C;&#x63A5;&#x8457;&#x5728;&#x5C08;&#x6848;&#x6839;&#x76EE;&#x9304;&#x4EE5;&#x547D;&#x4EE4;&#x5217;&#x57F7;&#x884C;<code>pre-commit install</code>&#xFF0C;&#x5C07;<code>.pre-commit-config.yaml</code>&#x8F49;&#x8B6F;&#x70BA;hook&#x8173;&#x672C;&#x5B58;&#x5728;&#x5C08;&#x6848;&#x4E0B;&#x7684;<code>.git/hooks</code>&#x76EE;&#x9304;&#x4E2D;:</p>
<pre><code class="language-bash">&gt; pre-commit install

pre-commit installed at .git\hooks\pre-commit</code></pre>
<p>&#x5230;&#x9019;&#x500B;&#x6B65;&#x9A5F;&#x5F8C;&#xFF0C;&#x57F7;&#x884C;<code>git commit</code>&#x5C31;&#x6703;&#x57F7;&#x884C;<code>.pre-commit-config.yaml</code>&#x8A2D;&#x5B9A;&#x7684;&#x5404;&#x500B;hook&#xFF0C;&#x5982;&#x679C;&#x662F;&#x5728;VSCode&#x57F7;&#x884C;&#xFF0C;&#x4E26;&#x6709;&#x4E0D;&#x7B26;&#x5408;&#x898F;&#x5B9A;&#x7684;&#x6703;&#x76F4;&#x63A5;&#x8DF3;&#x51FA;&#x8B66;&#x544A;&#xFF0C;&#x53EF;&#x4EE5;&#x67E5;&#x770B;&#x54EA;&#x500B;&#x74B0;&#x7BC0;&#x51FA;&#x932F;&#x4E86;:</p>
<figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/09/image-45.png" class="kg-image" alt="CI/CD Server Note 04" loading="lazy" width="723" height="323" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/09/image-45.png 600w, https://ghost.augustushsu.com/content/images/2023/09/image-45.png 723w" sizes="(min-width: 720px) 720px"></figure>
<p>&#x6309;&#x7167;<a href="https://pre-commit.com/?ref=ghost.augustushsu.com#4-optional-run-against-all-the-files">&#x5B98;&#x65B9;&#x7684;&#x6587;&#x6A94;</a>&#x8AAA;&#x660E;&#xFF0C;&#x5982;&#x679C;&#x6DFB;&#x52A0;&#x4E86;&#x65B0;&#x7684;hook&#x5EFA;&#x8B70;&#x57F7;&#x884C;&#x4EE5;&#x4E0B;&#x6307;&#x4EE4; (&#x6216;&#x662F;&#x4F60;&#x60F3;&#x8981;&#x624B;&#x52D5;&#x57F7;&#x884C;)&#xFF0C;&#x8B93;&#x6240;&#x6709;&#x7684;&#x6A94;&#x6848;&#x90FD;&#x6AA2;&#x67E5;&#x904E;&#x4E00;&#x6B21;:</p>
<pre><code class="language-bash">pre-commit run --all-files</code></pre>
<p>&#x9664;&#x4E86;&#x4F7F;&#x7528;&#x6240;&#x6709;&#x7684;hook&#x6AA2;&#x67E5;&#x6240;&#x6709;&#x7684;&#x6A94;&#x6848;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x6307;&#x5B9A;<code>hook-id</code>&#x6216;&#x7279;&#x5B9A;&#x7684;&#x6A94;&#x6848;&#x53BB;&#x57F7;&#x884C;:</p>
<pre><code class="language-bash"># &#x6307;&#x5B9A;hook&#x6AA2;&#x67E5;&#x6240;&#x6709;&#x6A94;&#x6848;
pre-commit run [hook-id] -a

# &#x6307;&#x5B9A;hook&#x6AA2;&#x67E5;&#x7279;&#x5B9A;&#x6A94;&#x6848;
pre-commit run [hook-id] --files &lt;file_1&gt; &lt;file_2&gt;</code></pre>
<div class="kg-card kg-callout-card kg-callout-card-grey"><div class="kg-callout-emoji">&#x1F4A1;</div><div class="kg-callout-text">&#x5C0F;&#x63D0;&#x9192;: pre-commit&#x6240;&#x6AA2;&#x67E5;&#x7684;&#x6A94;&#x6848;&#x53EA;&#x6709;&#x653E;&#x5230;&#x66AB;&#x5B58;&#x5340;&#x7684;&#x6A94;&#x6848;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x7D93;&#x904E;git add&#x7684;&#x6A94;&#x6848;&#xFF0C;&#x4F46;&#x5982;&#x679C;&#x4F7F;&#x7528;--all-files&#x53C3;&#x6578;&#x5247;&#x771F;&#x7684;&#x70BA;&#x6240;&#x6709;&#x6A94;&#x6848;&#x3002;</div></div>
<h3 id="%E8%B7%B3%E9%81%8E%E5%81%9C%E7%94%A8">&#x8DF3;&#x904E;/&#x505C;&#x7528;</h3>
<p>&#x5982;&#x679C;&#x8981;&#x8DF3;&#x904E;<code>pre-commit</code>&#x76F4;&#x63A5;commit&#x7684;&#x8A71;&#xFF0C;&#x5728;<code>git commit</code>&#x5F8C;&#x9762;&#x52A0;&#x4E0A;<code>--no-verify</code>&#x53C8;&#x53EF;&#x4EE5;&#x8DF3;&#x904E;&#x6AA2;&#x67E5;&#x4E86;:</p>
<pre><code class="language-bash">git commit --no-verify -m &quot;Commit Message&quot;</code></pre>
<p>&#x5982;&#x679C;&#x8981;&#x76F4;&#x63A5;&#x505C;&#x7528;<code>pre-commit</code>&#x76F4;&#x63A5;&#x8F38;&#x5165;&#x4EE5;&#x4E0B;&#x6307;&#x4EE4;&#x5C31;&#x53EF;&#x4EE5;&#x505C;&#x7528;&#x4E86;:</p>
<pre><code class="language-bash">pre-commit uninstal</code></pre>
<h2 id="%E5%85%B6%E4%BB%96hook">&#x5176;&#x4ED6;hook</h2>
<p>&#x524D;&#x9762;&#x6709;&#x63D0;&#x5230;&#x53EF;&#x4EE5;&#x5230;&#x5B98;&#x65B9;&#x63D0;&#x4F9B;&#x7684;<a href="https://pre-commit.com/hooks.html?ref=ghost.augustushsu.com">&#x53EF;&#x652F;&#x63F4;hooks&#x5217;&#x8868;</a>&#x4E2D;&#x5B89;&#x88DD;&#x9700;&#x8981;&#x7684;script&#xFF0C;&#x4E0B;&#x9762;&#x6703;&#x4ECB;&#x7D39;&#x5E7E;&#x500B;&#x76EE;&#x524D;&#x5728;&#x7528;&#x7684;hook&#xFF0C;&#x53EF;&#x4EE5;&#x8B93;&#x525B;&#x4E0A;&#x624B;&#x7684;&#x4EBA;&#x6709;&#x4E00;&#x500B;&#x57FA;&#x672C;&#x7684;&#x8A2D;&#x5B9A;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x3002;</p>
<h3 id="flake8">Flake8</h3>
<p><code>Flake8</code>&#x662F;&#x7528;&#x4F86;&#x6AA2;&#x67E5;python&#x7A0B;&#x5F0F;&#x78BC;&#x98A8;&#x683C;&#x548C;&#x627E;&#x5230;&#x7A0B;&#x5F0F;&#x78BC;&#x6F5B;&#x5728;&#x7684;&#x54C1;&#x8CEA;&#x554F;&#x984C;&#x4EE5;&#x7B26;&#x5408;<code>PEP8</code>&#xFF0C;&#x6709;&#x52A9;&#x65BC;&#x63D0;&#x9AD8;&#x7A0B;&#x5F0F;&#x78BC;&#x7684;&#x8CEA;&#x91CF;&#x3001;&#x53EF;&#x8B80;&#x6027;&#x548C;&#x53EF;&#x7DAD;&#x8B77;&#x6027;&#xFF0C;&#x95DC;&#x65BC;<code>Flake8</code>&#x7684;&#x4ECB;&#x7D39;&#x7DB2;&#x8DEF;&#x6709;&#x5F88;&#x591A;&#x4E86;&#xFF0C;&#x9019;&#x88E1;&#x5C31;&#x76F4;&#x63A5;&#x4E0A;&#x7BC4;&#x4F8B;:</p>
<pre><code class="language-yaml"># &#x524D;&#x7565;
  - repo: https://github.com/PyCQA/flake8
    rev: 6.1.0
    hooks:
      - id: flake8
        exclude: .venv/
        args:
          - --max-line-length=100
          - --ignore=E402</code></pre>
<p>&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x6BD4;&#x8D77;&#x524D;&#x9762;&#x7684;&#x5BEB;&#x6CD5;&#x591A;&#x4E86;<code>exclude</code>&#x8DDF;<code>args</code>&#x5169;&#x500B;&#x53C3;&#x6578;:</p>
<ul><li><code>exclude</code> : &#x6307;&#x5B9A;&#x9700;&#x8981;&#x6392;&#x9664;&#x6AA2;&#x67E5;&#x7684;&#x6A94;&#x6848;&#x6216;&#x8CC7;&#x6599;&#x593E;&#x3002;</li><li><code>args</code> : &#x8981;&#x50B3;&#x905E;&#x7D66;hook&#x7684;&#x9644;&#x52A0;&#x53C3;&#x6578;&#x6E05;&#x55AE;&#x3002;</li></ul>
<p>&#x9019;&#x88E1;&#x6392;&#x9664;&#x4E86;<code>.venv/</code>&#x8CC7;&#x6599;&#x593E;&#xFF0C;&#x4E14;&#x50B3;&#x5165;&#x4E86;<code>max-line-length=100</code>&#x548C;<code>ignore=E402</code>&#x5169;&#x500B;&#x53C3;&#x6578;&#x7D66;<code>Flake8</code>&#xFF0C;&#x5176;&#x4E2D;<code>max-line-length=100</code>&#x5C07;&#x9650;&#x5236;&#x9577;&#x5EA6;&#x5F9E;&#x539F;&#x672C;&#x7684;79&#x6539;&#x70BA;100&#xFF1B;&#x800C;<code>ignore</code>&#x5247;&#x662F;&#x8981;<code>Flake8</code>&#x5FFD;&#x7565;&#x67D0;&#x4E9B;&#x8B66;&#x544A;&#x6216;&#x662F;&#x932F;&#x8AA4;&#xFF0C;&#x9019;&#x88E1;&#x7684;<code>E402</code>&#x4EE3;&#x8868;&#x7684;&#x662F;import python&#x5957;&#x4EF6;&#x7684;&#x4F4D;&#x7F6E;&#x4E0D;&#x5728;&#x6A94;&#x6848;&#x7684;&#x9802;&#x90E8;&#x7684;&#x932F;&#x8AA4;&#xFF0C;<code>Flake8</code>&#x7684;&#x898F;&#x5247;&#x53EF;&#x4EE5;&#x5728;<a href="https://www.flake8rules.com/?ref=ghost.augustushsu.com">&#x9019;&#x88E1;</a>&#x67E5;&#x5230;&#xFF0C;&#x53EF;&#x4EE5;&#x6839;&#x64DA;&#x5718;&#x968A;&#x7684;&#x898F;&#x5B9A;&#x6216;&#x662F;&#x4E0D;&#x540C;&#x7684;&#x5C08;&#x6848;&#x4F86;&#x914D;&#x5408;&#x9700;&#x6C42;&#x3002;</p>
<h3 id="isort">isort</h3>
<p><code>isort</code>&#x4E3B;&#x8981;&#x662F;&#x5C07;import&#x9032;python&#x7684;&#x5957;&#x4EF6;&#x6309;&#x7167;&#x4E00;&#x5B9A;&#x7684;&#x898F;&#x5247;&#x6392;&#x5E8F;&#x3001;&#x5206;&#x7D44;&#xFF0C;&#x4E26;&#x6309;&#x7167;&#x5B57;&#x6BCD;&#x9806;&#x5E8F;&#x6392;&#x5217;&#xFF0C;&#x540C;&#x6A23;<code>isort</code>&#x4E5F;&#x7B26;&#x5408;<code>PEP8</code>&#x7684;&#x898F;&#x5B9A;&#xFF0C;&#x4EE5;&#x4E0B;&#x662F;&#x4F7F;&#x7528;<code>isort</code>&#x7684;&#x7BC4;&#x4F8B;:</p>
<pre><code class="language-yaml"># &#x524D;&#x7565;
  - repo: https://github.com/PyCQA/isort
    rev: 5.12.0
    hooks:
      - id: isort
        exclude: .venv/
        args:
          - --line-length=100
          - --profile=black</code></pre>
<p>&#x540C;&#x6A23;&#x5728;&#x9019;&#x88E1;&#x770B;&#x5230;&#x4E86;<code>line-length</code>&#xFF0C;&#x70BA;&#x4E86;&#x8B93;&#x5F7C;&#x6B64;&#x5171;&#x901A;&#x7684;&#x5224;&#x65B7;&#x898F;&#x5247;&#x4E00;&#x81F4;&#xFF0C;&#x8A2D;&#x5B9A;&#x70BA;100&#x3002;</p>
<h3 id="yapf">yapf</h3>
<p>yapf (Yet Another Python Formatter) &#x662F;&#x4E00;&#x500B;python&#x7A0B;&#x5F0F;&#x78BC;&#x683C;&#x5F0F;&#x5316;&#x5DE5;&#x5177;&#xFF0C;&#x5B83;&#x53EF;&#x4EE5;&#x5E6B;&#x52A9;&#x958B;&#x767C;&#x8005;&#x81EA;&#x52D5;&#x8ABF;&#x6574;python&#x7A0B;&#x5F0F;&#x78BC;&#x7684;&#x98A8;&#x683C;&#x548C;&#x683C;&#x5F0F;&#xFF0C;&#x4EE5;&#x78BA;&#x4FDD;&#x7A0B;&#x5F0F;&#x78BC;&#x7684;&#x4E00;&#x81F4;&#x6027;&#x548C;&#x53EF;&#x8B80;&#x6027;&#xFF0C;YAPF&#x6839;&#x64DA;PEP 8&#x898F;&#x7BC4;&#x81EA;&#x52D5;&#x683C;&#x5F0F;&#x5316;&#x4EE3;&#x78BC;&#xFF0C;&#x4F7F;&#x4EE3;&#x78BC;&#x98A8;&#x683C;&#x4E00;&#x81F4;&#xFF0C;&#x4E26;&#x6E1B;&#x5C11;&#x7A0B;&#x5F0F;&#x78BC;&#x5BE9;&#x67E5;&#x4E2D;&#x7684;&#x98A8;&#x683C;&#x554F;&#x984C;&#x3002;</p>
<p>&#x6309;&#x7167;<code>pre-commit</code>&#x652F;&#x63F4;&#x7684;hook&#x5B89;&#x88DD;&#x7684;&#x65B9;&#x5F0F;&#x53EF;&#x4EE5;&#x5728;.pre-commit-config.yaml&#x4E0A;&#x6DFB;&#x52A0;&#x4EE5;&#x4E0B;&#x4EE3;&#x78BC;:</p>
<pre><code class="language-yaml"># &#x524D;&#x7565;
  - repo: https://github.com/pre-commit/mirrors-yapf
    rev: v0.32.0
    hooks:
      - id: yapf
        exclude: .venv/
        args:
          - column_limit = 100
        additional_dependencies: [toml]</code></pre>
<p>&#x6216;&#x662F;&#x4F7F;&#x7528;google&#x7684;yapf&#xFF0C;&#x5B83;&#x63D0;&#x4F9B;&#x4E86;&#x8A31;&#x591A;&#x53EF;&#x4EE5;&#x5BA2;&#x88FD;&#x5316;&#x7684;&#x53C3;&#x6578;&#x8A2D;&#x5B9A;&#xFF0C;&#x8A73;&#x7D30;&#x7684;&#x8AAA;&#x660E;&#x53EF;&#x4EE5;&#x53BB;<a href="https://github.com/google/yapf?ref=ghost.augustushsu.com">github</a>&#x4E0A;&#x67E5;&#x770B;:</p>
<pre><code class="language-yaml"># &#x524D;&#x7565;
  - repo: https://github.com/google/yapf
    rev: v0.40.1
    hooks:
      - id: yapf
        name: yapf
        language: python
        entry: yapf
        args: 
          - -i
          - COLUMN_LIMIT = 100
        types: [python]</code></pre>
<h3 id="black">black </h3>
<p>black&#x8DDF;yapf&#x4E00;&#x6A23;&#x662F;&#x7A0B;&#x5F0F;&#x78BC;&#x683C;&#x5F0F;&#x5DE5;&#x5177;&#xFF0C;&#x4E0D;&#x904E;black&#x662F;&#x4EE5;&#x56B4;&#x683C;&#x7684;&#x898F;&#x7BC4;&#x51FA;&#x540D;&#xFF0C;&#x57FA;&#x672C;&#x4E0A;&#x6C92;&#x6709;&#x592A;&#x591A;&#x7684;&#x5BA2;&#x88FD;&#x5316;&#x53C3;&#x6578;&#x53EF;&#x4EE5;&#x8ABF;&#x6574;:</p>
<pre><code class="language-yaml">  - repo: https://github.com/psf/black
    rev: v23.9.1
    hooks:
    - id: black
      args:
        - --line-length=100
        - --skip-string-normalization
</code></pre>
<p>&#x5927;&#x81F4;&#x4E0A;&#x6703;&#x4F7F;&#x7528;&#x7684;&#x53C3;&#x6578;&#x5C31;&#x9019;&#x5169;&#x7A2E;&#xFF0C;&#x5176;&#x4ED6;&#x7684;&#x53C3;&#x6578;&#x53EF;&#x4EE5;&#x53C3;&#x8003;<a href="https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html?ref=ghost.augustushsu.com">&#x9019;&#x500B;&#x7DB2;&#x5740;</a>:</p>
<ul><li><code>--line-length</code>: &#x55AE;&#x884C;&#x7684;&#x9577;&#x5EA6;&#x9650;&#x5236;&#xFF0C;&#x9810;&#x8A2D;&#x70BA;88&#x3002;</li><li><code>--skip-string-normalization</code>: black&#x6703;&#x5C0D;&#x6240;&#x6709;&#x5B57;&#x4E32;&#x4F7F;&#x7528;&#x96D9;&#x5F15;&#x865F;&#x4E26;&#x6A19;&#x6E96;&#x5316;&#x5B57;&#x4E32;&#x3002;</li></ul>
<h2 id="linter-formatter">Linter &amp; Formatter</h2>
<p>&#x524D;&#x9762;&#x6240;&#x4ECB;&#x7D39;&#x7684;<code>Flake8</code>&#x8DDF;<code>yapf</code>&#x5206;&#x5225;&#x662F;&#x4E00;&#x7A2E;python&#x7684;Linter&#x8DDF;Formatter&#xFF0C;&#x7528;&#x4F86;&#x7D71;&#x4E00;&#x7A0B;&#x5F0F;&#x78BC;&#x98A8;&#x683C;&#x7684;&#x5DE5;&#x5177;&#xFF0C;&#x4F7F;&#x7528;&#x6B65;&#x9A5F;&#x901A;&#x5E38;&#x662F;:</p>
<ol><li>&#x5148;&#x7528;<strong>Linter</strong>&#x4F86;&#x6AA2;&#x67E5;&#x7A0B;&#x5F0F;&#x78BC;&#x4E2D;&#x7684;&#x6F5B;&#x5728;&#x554F;&#x984C;&#x3001;&#x98A8;&#x683C;&#x6307;&#x5357;&#x9055;&#x898F;&#x548C;&#x932F;&#x8AA4;&#xFF0C;&#x5B83;&#x6703;&#x63D0;&#x4F9B;&#x6709;&#x95DC;&#x4EE3;&#x78BC;&#x4E2D;&#x53EF;&#x80FD;&#x5B58;&#x5728;&#x7684;&#x554F;&#x984C;&#x7684;&#x8B66;&#x544A;&#x6216;&#x932F;&#x8AA4;&#x6D88;&#x606F;&#xFF0C;&#x5982;&#x672A;&#x5B9A;&#x7FA9;&#x7684;&#x8B8A;&#x6578;&#x3001;&#x672A;&#x4F7F;&#x7528;&#x7684;&#x8B8A;&#x6578;&#x3001;&#x4EE3;&#x78BC;&#x98A8;&#x683C;&#x4E0D;&#x7B26;&#x5408;&#x6163;&#x4F8B;&#x7B49;&#x3002;</li><li>&#x518D;&#x7528;<strong>Formatter</strong>&#x81EA;&#x52D5;&#x8ABF;&#x6574;&#x7A0B;&#x5F0F;&#x78BC;&#x7684;&#x683C;&#x5F0F;&#xFF0C;&#x4EE5;&#x7B26;&#x5408;&#x6307;&#x5B9A;&#x7684;&#x98A8;&#x683C;&#x6307;&#x5357;&#x548C;&#x6163;&#x4F8B;&#xFF0C;&#x5B83;&#x6703;&#x81EA;&#x52D5;&#x7CFE;&#x6B63;&#x7E2E;&#x9032;&#x3001;&#x7A7A;&#x683C;&#x3001;&#x63DB;&#x884C;&#x7B49;&#x98A8;&#x683C;&#x554F;&#x984C;&#xFF0C;&#x4EE5;&#x78BA;&#x4FDD;&#x4EE3;&#x78BC;&#x7684;&#x4E00;&#x81F4;&#x6027;&#x3002;</li></ol>
<p>&#x5E38;&#x898B;&#x7528;&#x65BC;python&#x7684;Linter&#x6709;&#x4E0B;&#x9762;&#x9019;&#x5E7E;&#x7A2E;:</p>
<ol><li><a href="https://github.com/pylint-dev/pylint?ref=ghost.augustushsu.com"><strong>Pylint</strong></a></li><li><a href="https://github.com/PyCQA/flake8?ref=ghost.augustushsu.com"><strong>Flake8</strong></a></li><li><a href="https://github.com/PyCQA/pycodestyle?ref=ghost.augustushsu.com"><strong>pycodestyle</strong></a> (&#x4EE5;&#x524D;&#x7684;&#x540D;&#x7A31;&#x662F;PEP8)</li></ol>
<p>&#x5E38;&#x898B;&#x7528;&#x65BC;python&#x7684;Formatter&#x6709;&#x4E0B;&#x9762;&#x9019;&#x5E7E;&#x7A2E;:</p>
<ol><li><a href="https://github.com/hhatto/autopep8?ref=ghost.augustushsu.com"><strong>autopep8</strong></a></li><li><a href="https://github.com/pre-commit/mirrors-yapf?ref=ghost.augustushsu.com"><strong>yapf</strong></a><strong> </strong>(<a href="https://github.com/google/yapf?ref=ghost.augustushsu.com">google&#x7248;&#x672C;&#x5728;&#x9019;</a>)</li><li><a href="https://github.com/psf/black?ref=ghost.augustushsu.com"><strong>Black</strong></a></li></ol>
<p>&#x7E3D;&#x7684;&#x4F86;&#x8AAA;&#xFF0C;&#x4F60;&#x61C9;&#x8A72;&#x9996;&#x5148;&#x904B;&#x884C; Linter &#x4F86;&#x6AA2;&#x67E5;&#x4EE3;&#x78BC;&#x4E2D;&#x7684;&#x554F;&#x984C;&#xFF0C;&#x7136;&#x5F8C;&#x518D;&#x904B;&#x884C; Formatter &#x4F86;&#x78BA;&#x4FDD;&#x4EE3;&#x78BC;&#x7B26;&#x5408;&#x98A8;&#x683C;&#x6307;&#x5357;&#x3002;&#x9019;&#x6A23;&#x53EF;&#x4EE5;&#x78BA;&#x4FDD;&#x4F60;&#x7684;&#x4EE3;&#x78BC;&#x65E2;&#x6C92;&#x6709;&#x932F;&#x8AA4;&#xFF0C;&#x53C8;&#x7B26;&#x5408;&#x4E00;&#x81F4;&#x7684;&#x98A8;&#x683C;&#xFF0C;&#x63D0;&#x9AD8;&#x4E86;&#x4EE3;&#x78BC;&#x7684;&#x54C1;&#x8CEA;&#x548C;&#x53EF;&#x7DAD;&#x8B77;&#x6027;&#x3002;</p>
<h2 id="%E4%BD%BF%E7%94%A8%E7%9A%84%E7%AF%84%E4%BE%8B">&#x4F7F;&#x7528;&#x7684;&#x7BC4;&#x4F8B;</h2>
<p>&#x8981;&#x6CE8;&#x610F;&#x5982;&#x679C;&#x6709;&#x5F7C;&#x6B64;&#x5171;&#x901A;&#x7684;&#x5224;&#x65B7;&#x898F;&#x5247;&#xFF0C;&#x90A3;&#x53C3;&#x6578;&#x8981;&#x8A18;&#x5F97;&#x8A2D;&#x5B9A;&#x4E00;&#x6A23;:</p>
<pre><code class="language-yaml">repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.4.0
    hooks:
      - id: trailing-whitespace
      - id: check-added-large-files
      - id: check-ast
      - id: check-case-conflict
      - id: check-json
      - id: check-toml
      - id: check-yaml
      - id: end-of-file-fixer

  - repo: https://github.com/PyCQA/flake8
    rev: 5.0.4
    hooks:
      - id: flake8
        exclude: migrations/
        args:
          - --max-line-length=100
          - --ignore=E131

  - repo: https://github.com/PyCQA/isort
    rev: 5.11.5
    hooks:
      - id: isort
        exclude: migrations/
        args:
          - --line-length=100
          - --profile=black

  # &#x9078;&#x64C7;black&#x6216;&#x662F;yapf
  - repo: https://github.com/google/yapf
    rev: v0.40.1
    hooks:
      - id: yapf
        name: yapf
        language: python
        entry: yapf
        args: 
          - -i
          - COLUMN_LIMIT = 100
        types: [python]

  - repo: https://github.com/psf/black
    rev: 23.9.1
    hooks:
      - id: black
        args:
          - --line-length=100
</code></pre>
<p></p>]]></content:encoded></item><item><title><![CDATA[Python Note 01]]></title><description><![CDATA[管理套件相依性、依賴性和虛擬環境的工具。]]></description><link>https://ghost.augustushsu.com/python-note-01/</link><guid isPermaLink="false">64fffa055677df0593b3814b</guid><category><![CDATA[Python-Note]]></category><dc:creator><![CDATA[AugustusHsu]]></dc:creator><pubDate>Sun, 24 Sep 2023 12:00:23 GMT</pubDate><media:content url="https://ghost.augustushsu.com/content/images/2023/09/python-note01-cover-1.png" medium="image"/><content:encoded><![CDATA[<h1 id="%E5%A5%97%E4%BB%B6%E3%80%81%E8%99%9B%E6%93%AC%E7%92%B0%E5%A2%83%E7%AE%A1%E7%90%86%E5%B7%A5%E5%85%B7-poetry">&#x5957;&#x4EF6;&#x3001;&#x865B;&#x64EC;&#x74B0;&#x5883;&#x7BA1;&#x7406;&#x5DE5;&#x5177;-Poetry</h1>
<img src="https://ghost.augustushsu.com/content/images/2023/09/python-note01-cover-1.png" alt="Python Note 01"><p>&#x4F7F;&#x7528;Python&#x4F86;&#x958B;&#x767C;&#x8EDF;&#x9AD4;&#x6642;&#xFF0C;&#x7BA1;&#x7406;&#x5728;&#x5C08;&#x6848;&#x4E2D;&#x4F7F;&#x7528;&#x7684;&#x5957;&#x4EF6;&#x548C;Python&#x7248;&#x672C;&#x662F;&#x4E00;&#x4EF6;&#x9EBB;&#x7169;&#x7684;&#x4E8B;&#x60C5;&#xFF0C;&#x5F9E;&#x4E00;&#x958B;&#x59CB;&#x63A5;&#x89F8;&#x7684;<code>pip install</code>&#x3001;&#x6216;&#x662F;&#x7BA1;&#x7406;&#x4E0D;&#x540C;&#x5C08;&#x6848;&#x7684;&#x865B;&#x64EC;&#x74B0;&#x5883;<code>conda</code>&#x4F86;&#x5B89;&#x88DD;&#x4E0D;&#x540C;&#x7248;&#x672C;&#x7684;Python&#x6216;&#x662F;&#x5957;&#x4EF6;&#xFF0C;&#x90FD;&#x6216;&#x591A;&#x6216;&#x5C11;&#x6703;&#x6709;&#x4E00;&#x4E9B;&#x76F8;&#x4F9D;&#x6027;&#x7684;&#x554F;&#x984C;&#x3002;</p>
<p>&#x5C24;&#x5176;&#x662F;&#x4F7F;&#x7528;<code>pip uninstall</code>&#x7684;&#x6642;&#x5019;&#xFF0C;&#x89E3;&#x9664;&#x5B89;&#x88DD;&#x5957;&#x4EF6;&#x6642;&#x5C31;&#x53EA;&#x6703;&#x89E3;&#x9664;&#x5B89;&#x88DD;&#x4F60;&#x6307;&#x5B9A;&#x7684;&#x5957;&#x4EF6;&#xFF0C;&#x5176;&#x4ED6;&#x76F8;&#x4F9D;&#x7684;&#x5957;&#x4EF6;&#x901A;&#x5E38;&#x90FD;&#x4E0D;&#x6703;&#x88AB;&#x4E00;&#x4F75;&#x89E3;&#x9664;&#x5B89;&#x88DD;&#xFF0C;&#x9019;&#x5C31;&#x6703;&#x9047;&#x5230;&#x4E00;&#x4E9B;&#x95DC;&#x65BC;&#x76F8;&#x4F9D;&#x6027;&#x7684;&#x554F;&#x984C;&#xFF0C;&#x9918;&#x4E0B;&#x7684;&#x5957;&#x4EF6;&#x53EF;&#x80FD;&#x6703;&#x548C;&#x4E4B;&#x5F8C;&#x65B0;&#x5B89;&#x88DD;&#x7684;&#x5957;&#x4EF6;&#x7522;&#x751F;<strong>&#x885D;&#x7A81;</strong>&#xFF0C;&#x6240;&#x4EE5;&#x6211;&#x5011;&#x9700;&#x8981;&#x4E00;&#x500B;&#x5B8C;&#x6574;&#x7684;&#x5957;&#x4EF6;&#x76F8;&#x4F9D;&#x6027;&#x7BA1;&#x7406;&#x5DE5;&#x5177;&#x4F86;&#x8655;&#x7406;&#x9019;&#x500B;&#x554F;&#x984C;&#xFF0C;&#x800C;<code>Poetry</code>&#x5C31;&#x662F;&#x8CA0;&#x8CAC;&#x7BA1;&#x7406;&#x5957;&#x4EF6;&#x76F8;&#x4F9D;&#x6027;&#x3001;&#x4F9D;&#x8CF4;&#x6027;&#x548C;&#x865B;&#x64EC;&#x74B0;&#x5883;&#x7684;&#x5DE5;&#x5177;&#x3002;</p>
<p><code>poetry</code>&#x5177;&#x9AD4;&#x7684;&#x6307;&#x4EE4;&#x6216;&#x65B9;&#x6CD5;&#x5EFA;&#x8B70;&#x53C3;&#x8003;<a href="https://python-poetry.org/docs/?ref=ghost.augustushsu.com">&#x5B98;&#x65B9;&#x7DB2;&#x7AD9;</a>&#x7684;&#x6307;&#x4EE4;&#xFF0C;</p>
<h2 id="%E5%AE%89%E8%A3%9Dpoetry">&#x5B89;&#x88DD;Poetry</h2>
<p>&#x5B89;&#x88DD;<code>poetry</code>&#x5728;Windows&#x9700;&#x8981;&#x4F7F;&#x7528;Powershell&#x4F86;&#x5B89;&#x88DD;&#xFF0C;&#x6253;&#x958B;Powershell&#x8F38;&#x5165;&#x4EE5;&#x4E0B;&#x6307;&#x4EE4;(&#x76EE;&#x524D;&#x5B89;&#x88DD;&#x7684;&#x7248;&#x672C;&#x70BA;1.6.1) :</p>
<pre><code class="language-Powershell">(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | py -</code></pre>
<p>&#x5982;&#x679C;&#x662F;linux&#x3001;macOS&#x6216;&#x662F;Windows&#x7684;WSL&#x5247;&#x662F;&#x7528;&#x4EE5;&#x4E0B;&#x6307;&#x4EE4;&#xFF0C;&#x5982;&#x679C;&#x9700;&#x8981;&#x5B89;&#x88DD;python2&#x7684;poetry&#x6307;&#x4EE4;&#x5167;&#x7684;python3&#x53EF;&#x4EE5;&#x66F4;&#x6539;&#x70BA;python2:</p>
<pre><code class="language-bash">curl -sSL https://install.python-poetry.org | python3 -</code></pre>
<p>&#x5982;&#x679C;&#x5B89;&#x88DD;&#x6642;&#x9047;&#x5230;:</p>
<pre><code class="language-bash">Poetry installation failed.
See /home/username/poetry-installer-error-4khp4juv.log for error logs.</code></pre>
<p>&#x53BB;&#x770B;log&#x6703;&#x767C;&#x73FE;&#x7F3A;&#x5C11;<code>distutils</code>&#xFF0C;&#x9019;&#x662F;&#x7528;&#x65BC;&#x5354;&#x52A9;&#x5EFA;&#x7ACB;&#x548C;&#x5206;&#x767C;Python&#x5957;&#x4EF6;&#x7684;&#x5DE5;&#x5177;:</p>
<pre><code class="language-bash">ModuleNotFoundError: No module named &apos;distutils.cmd&apos;</code></pre>
<p>&#x9700;&#x8981;&#x4F60;&#x5B89;&#x88DD;<code>python3-distutils</code>&#xFF0C;&#x7528;&#x4EE5;&#x4E0B;&#x6307;&#x4EE4;&#x5B89;&#x88DD;:</p>
<pre><code class="language-bash">sudo apt-get install python3-distutils</code></pre>
<p>&#x5982;&#x679C;&#x662F;Windows&#x5B89;&#x88DD;&#x5B8C;&#x7684;&#x4F4D;&#x7F6E;&#x6703;&#x5728;<code>%APPDATA%\Python\Scripts</code>&#x800C;Unix&#x7CFB;&#x7D71;&#x5247;&#x662F;&#x5728;<code>$HOME/.local/bin</code>&#x4E0A;&#xFF0C;&#x5982;&#x679C;&#x8981;&#x76F4;&#x63A5;&#x4F7F;&#x7528;&#x8981;&#x8A2D;&#x5B9A;&#x74B0;&#x5883;&#x8B8A;&#x6578;PATH&#xFF0C;Windows&#x76F4;&#x63A5;&#x4F7F;&#x7528;&#x4EE5;&#x4E0B;&#x6307;&#x4EE4;&#x6216;&#x662F;&#x524D;&#x5F80;&#x74B0;&#x5883;&#x8B8A;&#x6578;&#x8A2D;&#x5B9A;&#x7684;&#x5730;&#x65B9;&#x65B0;&#x589E;&#x5373;&#x53EF;&#xFF0C;&#x5176;&#x4E2D;&#x7684;&#x4F7F;&#x7528;&#x8005;&#x8981;&#x8A18;&#x5F97;&#x6539;&#x70BA;&#x81EA;&#x5DF1;&#x7684;&#x4F7F;&#x7528;&#x8005;&#x540D;&#x7A31;:</p>
<pre><code class="language-Powershell">$Env:Path += &quot;;C:\Users\YourUserName\AppData\Roaming\Python\Scripts&quot;; setx PATH &quot;$Env:Path&quot;</code></pre>
<p>Unix&#x7CFB;&#x7D71;&#x5247;&#x662F;&#x8981;&#x5728;<code>.zshrc</code>&#x3001;<code>.bashrc</code>&#x6216;<code>.bash_profile</code>&#x65B0;&#x589E;&#x4EE5;&#x4E0B;&#x7684;&#x6307;&#x4EE4;:</p>
<pre><code class="language-bash">export PATH=$PATH:$HOME/.local/bin</code></pre>
<p>&#x5B89;&#x88DD;&#x5B8C;&#x5F8C;&#x6703;&#x767C;&#x73FE;&#x5982;&#x679C;&#x6309;&#x4E0B;<code>TAB</code>&#x662F;&#x7121;&#x6CD5;&#x88DC;&#x5168;&#x5269;&#x9918;&#x7684;&#x5B57;&#x4E32;&#x7684;&#xFF0C;&#x5982;&#x679C;&#x662F;&#x5728;Unix&#x4E0B;&#x4F7F;&#x7528;bash&#xFF0C;&#x52A0;&#x4E0A;&#x4EE5;&#x4E0B;&#x9019;&#x6BB5;&#x53EF;&#x4EE5;&#x6062;&#x5FA9;&#x88DC;&#x5168;&#x529F;&#x80FD;:</p>
<pre><code class="language-bash">poetry completions bash &gt;&gt; ~/.bash_completion</code></pre>
<h2 id="%E5%88%9D%E5%A7%8B%E5%8C%96poetry%E5%B0%88%E6%A1%88">&#x521D;&#x59CB;&#x5316;Poetry&#x5C08;&#x6848;</h2>
<p>&#x4F7F;&#x7528;Poetry&#x7684;&#x8A71;&#x9700;&#x8981;&#x5728;&#x4F60;&#x4F7F;&#x7528;Poetry&#x7684;&#x8CC7;&#x6599;&#x593E;&#x4F7F;&#x7528;&#x4EE5;&#x4E0B;&#x6307;&#x4EE4;&#xFF0C;&#x6703;&#x8DF3;&#x51FA;&#x4E00;&#x9023;&#x4E32;&#x7684;&#x4E92;&#x52D5;&#x5C0D;&#x8A71;&#x5354;&#x52A9;&#x5EFA;&#x7ACB;&#x5C08;&#x6848;&#xFF0C;&#x5176;&#x4E2D;&#x6703;&#x554F;&#x4F60;&#x662F;&#x5426;&#x8981;&#x4EE5;&#x4E92;&#x52D5;&#x65B9;&#x5F0F;&#x5B9A;&#x7FA9;&#x4F60;&#x7684;<strong>main/development</strong>&#x4F9D;&#x8CF4;&#x9019;&#x5169;&#x500B;&#x554F;&#x984C;&#xFF0C;&#x9019;&#x5169;&#x500B;&#x6211;&#x90FD;&#x9078;no&#xFF0C;&#x800C;&#x6700;&#x5F8C;&#x6703;print&#x51FA;&#x4F60;&#x7684;&#x8A2D;&#x5B9A;&#x6A94;&#x5167;&#x5BB9;&#x8981;&#x4F60;&#x78BA;&#x8A8D;:</p>
<pre><code class="language-bash">poetry init</code></pre>
<p>&#x7D50;&#x675F;&#x5F8C;&#x6703;&#x65B0;&#x589E;&#x4E00;&#x500B;<code>pyproject.toml</code>&#x505A;&#x70BA;&#x8A2D;&#x5B9A;&#x6A94;:</p>
<pre><code class="language-toml">[tool.poetry]
name = &quot;your_project_name&quot;
version = &quot;0.1.0&quot;
description = &quot;&quot;
authors = [&quot;AuthorName &lt;your@email.com&gt;&quot;]
readme = &quot;README.md&quot;

[tool.poetry.dependencies]
python = &quot;^3.10.11&quot;


[build-system]
requires = [&quot;poetry-core&quot;]
build-backend = &quot;poetry.core.masonry.api&quot;
</code></pre>
<div class="kg-card kg-callout-card kg-callout-card-grey"><div class="kg-callout-emoji">&#x1F4A1;</div><div class="kg-callout-text">&#x5728;&#x9019;&#x88E1;python&#x7248;&#x672C;&#x865F;&#x8981;&#x628A;&#x5F8C;&#x9762;&#x7684;.11&#x4E5F;&#x5217;&#x51FA;&#x4F86;&#xFF0C;&#x6211;&#x5728;&#x5F8C;&#x7E8C;&#x4F7F;&#x7528;poetry add&#x7684;&#x6642;&#x5019;&#x767C;&#x73FE;&#x5957;&#x4EF6;&#x5B89;&#x88DD;&#x7684;&#x901F;&#x5EA6;&#x975E;&#x5E38;&#x5730;&#x6162;&#xFF0C;&#x52A0;&#x4E0A;&#x5F8C;&#x5C31;&#x6B63;&#x5E38;&#x4E86;&#x3002;</div></div>
<p>&#x9664;&#x4E86;&#x4F7F;&#x7528;<code>init</code>&#x5916;&#xFF0C;&#x9084;&#x53EF;&#x4EE5;&#x7528;new&#x7684;&#x65B9;&#x5F0F;&#x5EFA;&#x7ACB;&#x5C08;&#x6848;&#xFF0C;&#x9664;&#x4E86;&#x6703;&#x5EFA;&#x7ACB;<code>pyproject.toml</code>&#x4EE5;&#x5916;&#x9084;&#x6703;&#x5EFA;&#x69CB;&#x4E00;&#x4E9B;&#x8CC7;&#x6599;&#x593E;&#x6216;&#x6A94;&#x6848;&#xFF0C;&#x5F8C;&#x9762;&#x53EF;&#x4EE5;&#x63A5;&#x4E0A;&#x4F60;&#x5C08;&#x6848;&#x540D;&#x7A31;&#x5C07;&#x5C08;&#x6848;&#x8CC7;&#x6599;&#x593E;&#x5EFA;&#x7ACB;&#x5728;&#x4F60;&#x76EE;&#x524D;&#x7684;&#x4F4D;&#x7F6E;&#x4E0A;&#xFF0C;&#x6216;&#x662F;&#x52A0;&#x4E0A;&#x8DEF;&#x5F91;&#x5EFA;&#x7ACB;&#x5728;&#x4F60;&#x6307;&#x5B9A;&#x7684;&#x8CC7;&#x6599;&#x593E;&#x5167;:</p>
<pre><code class="language-bash">poetry new your_project
poetry new your_project_path</code></pre>
<h2 id="%E5%BB%BA%E7%AB%8B%E9%80%B2%E5%85%A5python%E8%99%9B%E6%93%AC%E7%92%B0%E5%A2%83">&#x5EFA;&#x7ACB;/&#x9032;&#x5165;Python&#x865B;&#x64EC;&#x74B0;&#x5883;</h2>
<p>Poetry&#x9810;&#x8A2D;&#x5EFA;&#x7ACB;&#x865B;&#x64EC;&#x74B0;&#x5883;&#x7684;&#x4F4D;&#x7F6E;&#x5728;<code>C:\Users\YourUserName\AppData\Local\pypoetry\Cache\virtualenvs</code>&#xFF0C;&#x53EF;&#x4EE5;&#x900F;&#x904E;&#x8A2D;&#x5B9A;&#x5C07;&#x5EFA;&#x7ACB;&#x865B;&#x64EC;&#x74B0;&#x5883;&#x7684;&#x8DEF;&#x5F91;&#x6539;&#x5728;&#x5C08;&#x6848;&#x4E0B;&#xFF0C;&#x9996;&#x5148;&#x4F7F;&#x7528;&#x4EE5;&#x4E0B;&#x6307;&#x4EE4;&#x5217;&#x51FA;poetry&#x7684;&#x8A2D;&#x5B9A;:</p>
<pre><code class="language-bash">poetry config --list</code></pre>
<p>&#x5728;Windows&#x7684;&#x8A2D;&#x5B9A;&#x5167;&#x5BB9;&#x5982;&#x4E0B;&#xFF0C;&#x5176;&#x4E2D;&#x8981;&#x4FEE;&#x6539;<code>virtualenvs.in-project = null</code>&#xFF0C;&#x8B93;&#x865B;&#x64EC;&#x74B0;&#x5883;&#x7684;&#x8DEF;&#x5F91;&#x6539;&#x70BA;&#x4F60;&#x5C08;&#x6848;&#x76EE;&#x9304;:</p>
<pre><code class="language-bash">cache-dir = &quot;C:\\Users\\YourUserName\\AppData\\Local\\pypoetry\\Cache&quot;
experimental.system-git-client = false
installer.max-workers = null
installer.modern-installation = true
installer.no-binary = null
installer.parallel = true
virtualenvs.create = true
virtualenvs.in-project = null
virtualenvs.options.always-copy = false
virtualenvs.options.no-pip = false
virtualenvs.options.no-setuptools = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = &quot;{cache-dir}\\virtualenvs&quot;  # C:\Users\YourUserName\AppData\Local\pypoetry\Cache\virtualenvs
virtualenvs.prefer-active-python = false
virtualenvs.prompt = &quot;{project_name}-py{python_version}&quot;</code></pre>
<p>&#x4F7F;&#x7528;&#x4EE5;&#x4E0B;&#x6307;&#x4EE4;&#x5C31;&#x53EF;&#x4EE5;&#x66F4;&#x6539;&#x8A2D;&#x5B9A;:</p>
<pre><code class="language-bash">poetry config virtualenvs.in-project true</code></pre>
<p>&#x7528;&#x4EE5;&#x4E0B;&#x6307;&#x4EE4;&#x5EFA;&#x7ACB;&#x865B;&#x64EC;&#x74B0;&#x5883;&#xFF0C;&#x5176;&#x4E2D;python&#x53EF;&#x4EE5;&#x6539;&#x70BA;&#x4F60;&#x8981;&#x4F7F;&#x7528;&#x7684;python&#x8DEF;&#x5F91;&#xFF0C;&#x56E0;&#x70BA;&#x5DF2;&#x7D93;&#x5C07;&#x865B;&#x64EC;&#x74B0;&#x5883;&#x5EFA;&#x7ACB;&#x7684;&#x8DEF;&#x5F91;&#x6539;&#x70BA;&#x5C08;&#x6848;&#x5167;&#xFF0C;&#x6240;&#x4EE5;&#x5728;&#x5C08;&#x6848;&#x5167;&#x6703;&#x5EFA;&#x7ACB;<code>.venv</code>&#x7684;&#x8CC7;&#x6599;&#x593E;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x4F60;&#x7684;python&#x865B;&#x64EC;&#x74B0;&#x5883;:</p>
<pre><code class="language-bash">poetry env use python</code></pre>
<p>&#x53EF;&#x4EE5;&#x5728;Windows&#x4F7F;&#x7528;where&#x6307;&#x4EE4;&#x6216;&#x5728;Linux&#x4F7F;&#x7528;which&#x627E;&#x5230;&#x4F60;&#x7684;python&#x5B89;&#x88DD;&#x8DEF;&#x5F91;:</p>
<pre><code class="language-bash">where python
which python3</code></pre>
<p>&#x5EFA;&#x7ACB;&#x865B;&#x64EC;&#x74B0;&#x5883;&#x5F8C;&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;<code>poetry shell</code>&#x9032;&#x5165;&#x865B;&#x64EC;&#x74B0;&#x5883;:</p>
<pre><code class="language-bash">poetry shell</code></pre>
<div class="kg-card kg-callout-card kg-callout-card-grey"><div class="kg-callout-emoji">&#x1F4A1;</div><div class="kg-callout-text">&#x7576;&#x4F60;&#x7684;&#x5C08;&#x6848;&#x9084;&#x6C92;&#x6709;&#x5EFA;&#x7ACB;&#x865B;&#x64EC;&#x74B0;&#x5883;&#x6642;&#xFF0C;&#x4F7F;&#x7528;poetry shell&#x4E5F;&#x6703;&#x9806;&#x5E36;&#x5EFA;&#x7ACB;&#x865B;&#x64EC;&#x74B0;&#x5883;&#xFF0C;&#x4E0D;&#x904E;&#x662F;&#x4F7F;&#x7528;&#x9810;&#x8A2D;&#x7248;&#x672C;python&#x4F86;&#x5EFA;&#x7ACB;&#x865B;&#x64EC;&#x74B0;&#x5883;&#x3002;</div></div>
<p>&#x6307;&#x4EE4;&#x6703;&#x5075;&#x6E2C;&#x7576;&#x524D;&#x7684;&#x76EE;&#x9304;&#x6216;&#x4E0A;&#x4E00;&#x5C64;&#x76EE;&#x9304;&#x662F;&#x5426;&#x5B58;&#x5728;<code>pyporject.toml</code>&#x4F86;&#x78BA;&#x5B9A;&#x8981;&#x555F;&#x52D5;&#x7684;&#x865B;&#x64EC;&#x74B0;&#x5883;&#xFF0C;&#x5982;&#x679C;&#x6C92;&#x6709;&#x6703;&#x51FA;&#x73FE;&#x4EE5;&#x4E0B;&#x932F;&#x8AA4;:</p>
<pre><code class="language-bash">&gt; poetry shell

Poetry could not find a pyproject.toml file in /currnet/path or its parents</code></pre>
<p>&#x9000;&#x51FA;&#x8DDF;&#x4E00;&#x822C;&#x9032;&#x5165;&#x74B0;&#x5883;&#x7684;&#x65B9;&#x5F0F;&#x4E00;&#x6A23;&#xFF0C;&#x4F7F;&#x7528;<code>exit</code>&#x5373;&#x53EF;&#x3002;</p>
<h2 id="poetry%E5%B8%B8%E7%94%A8%E6%8C%87%E4%BB%A4">Poetry&#x5E38;&#x7528;&#x6307;&#x4EE4;</h2>
<p>Poetry&#x5728;&#x4F7F;&#x7528;&#x7684;&#x6642;&#x5019;&#x8DDF;<code>Anaconda</code>&#x5F88;&#x50CF;&#xFF0C;&#x90FD;&#x662F;&#x900F;&#x904E;&#x81EA;&#x5DF1;&#x7684;&#x6307;&#x4EE4;&#x4F86;&#x5EFA;&#x7ACB;&#x3001;&#x7BA1;&#x7406;&#x4F60;&#x7684;python&#x865B;&#x64EC;&#x74B0;&#x5883;&#xFF0C;&#x6BD4;&#x8D77;<code>Anaconda</code>&#x6216;&#x662F;<code>PyPI</code>&#x4ED6;&#x4F7F;&#x7528;&#x7684;&#x65B9;&#x5F0F;&#x8907;&#x96DC;&#x4E86;&#x4E00;&#x4E9B;&#xFF0C;&#x9700;&#x8981;&#x82B1;&#x8CBB;&#x4E00;&#x4E9B;&#x6642;&#x9593;&#x4F86;&#x5B78;&#x7FD2;&#x3002;</p>
<h3 id="poetry-add">poetry add</h3>
<p><code>poetry add</code>&#x8DDF;<code>pip install</code>&#x6216;<code>conda install</code>&#x4E00;&#x6A23;&#x662F;&#x7528;&#x4F86;&#x5B89;&#x88DD;&#x5957;&#x4EF6;&#x7684;&#xFF0C;&#x9019;&#x88E1;&#x793A;&#x7BC4;&#x5B89;&#x88DD;<code>pandas</code>&#xFF0C;&#x53EF;&#x4EE5;&#x6E05;&#x695A;&#x5730;&#x770B;&#x5230;&#x5B89;&#x88DD;&#x4E86;&#x54EA;&#x4E00;&#x4E9B;&#x5957;&#x4EF6;:</p>
<pre><code class="language-bash">poetry add pandas</code></pre>
<pre><code class="language-bash">Using version ^2.1.0 for pandas

Updating dependencies
Resolving dependencies...

Writing lock file

Package operations: 5 installs, 0 updates, 0 removals

  &#x2022; Installing six (1.16.0)
  &#x2022; Installing python-dateutil (2.8.2)
  &#x2022; Installing pytz (2023.3.post1)
  &#x2022; Installing tzdata (2023.3)
  &#x2022; Installing pandas (2.1.0)</code></pre>
<p>&#x6253;&#x958B;<code>pyproject.toml</code>&#x6703;&#x767C;&#x73FE;&#x5728;<code>tool.poetry.dependencies</code>&#x591A;&#x4E86;<code>pandas</code>&#x548C;&#x5B83;&#x5C0D;&#x61C9;&#x7684;&#x7248;&#x672C;&#x865F;:</p>
<pre><code class="language-bash">[tool.poetry.dependencies]
python = &quot;3.10.10&quot;
pandas = &quot;^2.1.0&quot;</code></pre>
<h3 id="poetry-lock">poetry lock</h3>
<p><code>poetry add</code>&#x9664;&#x4E86;&#x6703;&#x66F4;&#x65B0;<code>pyproject.toml</code>&#x4EE5;&#x5916;&#xFF0C;&#x9084;&#x6703;&#x6839;&#x64DA;&#x76EE;&#x524D;&#x5C08;&#x6848;&#x4E2D;<code>pyproject.toml</code>&#x5167;&#x7684;&#x8A2D;&#x5B9A;&#x7522;&#x751F;<code>poetry.lock</code>&#x6A94;&#x6848;&#xFF0C;&#x8A73;&#x7D30;&#x8A18;&#x8F09;&#x4E86;&#x6240;&#x6709;&#x5B89;&#x88DD;&#x7684;&#x5957;&#x4EF6;&#x8207;&#x5C0D;&#x61C9;&#x7684;&#x7248;&#x672C;&#x3001;&#x4F9D;&#x8CF4;&#x7684;&#x5957;&#x4EF6;&#x3002;</p>
<p>&#x6240;&#x4EE5;&#x5927;&#x9AD4;&#x4E0A;Poetry&#x7BA1;&#x7406;&#x5957;&#x4EF6;&#x7684;&#x6D41;&#x7A0B;&#x662F;:</p>
<ol><li>&#x66F4;&#x65B0;<code>pyproject.toml</code></li><li>&#x4F9D;&#x7167;<code>pyproject.toml</code>&#x5167;&#x7684;&#x8A2D;&#x5B9A;&#x66F4;&#x65B0;<code>poetry.lock</code></li><li>&#x6839;&#x64DA;<code>poetry.lock</code>&#x5275;&#x5EFA;&#x5C0D;&#x61C9;&#x7684;&#x865B;&#x64EC;&#x74B0;&#x5883;<code>.venv</code></li></ol>
<p>&#x6240;&#x4EE5;&#x8AAA;Poetry&#x4E2D;&#x7684;&#x6307;&#x4EE4;&#x53EA;&#x8981;&#x6709;&#x6D89;&#x53CA;&#x5230;&#x5C0D;&#x5957;&#x4EF6;&#x9032;&#x884C;&#x66F4;&#x6539;&#x7684;&#x90E8;&#x5206;&#xFF0C;&#x90FD;&#x662F;&#x6703;&#x6309;&#x7167;&#x9019;&#x500B;&#x6D41;&#x7A0B;&#x53BB;&#x9032;&#x884C;&#xFF0C;&#x5982;&#x679C;&#x4E0D;&#x4F7F;&#x7528;&#x6307;&#x4EE4;&#x64CD;&#x4F5C;&#x76F4;&#x63A5;&#x5C0D;<code>pyproject.toml</code>&#x9032;&#x884C;&#x66F4;&#x6539;&#xFF0C;&#x8B6C;&#x5982;&#x8ABF;&#x6574;&#x7279;&#x5B9A;&#x5957;&#x4EF6;&#x7684;&#x7248;&#x672C;&#xFF0C;&#x9019;&#x6642;&#x5019;<code>pyproject.toml</code>&#x548C;<code>poetry.lock</code>&#x4E4B;&#x9593;&#x5C31;&#x5931;&#x53BB;&#x4E86;&#x5C0D;&#x61C9;&#x7684;&#x95DC;&#x4FC2;&#xFF0C;&#x9700;&#x8981;&#x900F;&#x904E;<code>poetry lock</code>&#x9019;&#x6307;&#x4EE4;&#x8B93;Poetry&#x4F9D;&#x7167;<code>pyproject.toml</code>&#x5167;&#x7684;&#x8A2D;&#x5B9A;&#xFF0C;&#x4F86;&#x66F4;&#x65B0;<code>poetry.lock</code>&#x3002;</p>
<p>&#x8B6C;&#x5982;&#x6211;&#x66F4;&#x6539;&#x4E86;&#x4E4B;&#x524D;&#x5B89;&#x88DD;&#x7684;<code>pandas</code>&#x5957;&#x4EF6;&#x7248;&#x672C;&#xFF0C;<code>^</code>&#x7684;&#x610F;&#x601D;&#x662F;&#x4EFB;&#x4F55;&#x5927;&#x65BC;&#x6216;&#x7B49;&#x65BC; 2.1.0 &#x4E14;&#x5C0F;&#x65BC; 3.0.0&#x7684;&#x7248;&#x672C;&#xFF0C;&#x6240;&#x4EE5;&#x6539;&#x70BA; (&#x4E0D;&#x52A0;&#x4E0A;<code>^</code>) 2.0.0 :</p>
<pre><code class="language-toml">[tool.poetry.dependencies]
python = &quot;3.10.10&quot;
pandas = &quot;2.0.0&quot;           # &#x539F;&#x70BA;^2.1.0</code></pre>
<p>&#x4F7F;&#x7528;<code>poetry lock</code>&#x4F86;&#x66F4;&#x65B0;<code>poetry.lock</code>&#x6A94;&#x6848;:</p>
<pre><code class="language-bash">&gt; poetry lock

Updating dependencies
Resolving dependencies...

Writing lock file</code></pre>
<p>&#x5728;<code>poetry.lock</code>&#x4E0A;&#x6703;&#x770B;&#x5230;&#x66F4;&#x65B0;&#x5F8C;&#x5C0D;&#x61C9;&#x7684;&#x7248;&#x672C;:</p>
<pre><code class="language-toml"># &#x524D;&#x7565;
[[package]]
name = &quot;pandas&quot;
version = &quot;2.0.0&quot;
# &#x5F8C;&#x7565;</code></pre>
<p>&#x63A5;&#x4E0B;&#x4F86;&#x9084;&#x6709;&#x6700;&#x5F8C;&#x4E00;&#x6B65;&#x9A5F;&#xFF0C;&#x5C31;&#x662F;&#x628A;<code>poetry.lock</code>&#x7684;&#x66F4;&#x6539;&#x5BEB;&#x5165;&#x5C0D;&#x61C9;&#x865B;&#x64EC;&#x74B0;&#x5883;:</p>
<pre><code class="language-bash">poetry install --sync</code></pre>
<ul><li>&#x5982;&#x679C;&#x7576;&#x524D;&#x76EE;&#x9304;&#x4E2D;&#x6709;<code>poetry.lock</code>&#x6587;&#x4EF6;&#xFF0C;<code>poetry install</code>&#x6703;&#x4F7F;&#x7528;&#x90A3;&#x88E1;&#x7684;&#x78BA;&#x5207;&#x7248;&#x672C;&#x3002;</li><li>&#x5982;&#x679C;&#x6C92;&#x6709;<code>poetry.lock</code>&#xFF0C;&#x6703;&#x5F9E;&#x7576;&#x524D;&#x5C08;&#x6848;&#x4E2D;&#x8B80;&#x53D6;<code>pyproject.toml</code>&#x6587;&#x4EF6;&#xFF0C;&#x89E3;&#x6790;&#x4F9D;&#x8CF4;&#x9805;&#x4E26;&#x5B89;&#x88DD;&#x5B83;&#x5011;&#x3002;</li></ul>
<h3 id="poetry-update">poetry update</h3>
<p><code>poetry update</code>&#x7684;&#x4F5C;&#x7528;&#x5C31;&#x662F;&#x66F4;&#x65B0;&#x5957;&#x4EF6;&#xFF0C;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x4F7F;&#x7528;&#x6307;&#x4EE4;&#x66F4;&#x65B0;&#x76EE;&#x524D;&#x6240;&#x6709;&#x6709;&#x7528;&#x5230;&#x7684;&#x5957;&#x4EF6;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x91DD;&#x5C0D;&#x7279;&#x5B9A;&#x7684;&#x5957;&#x4EF6;&#x9032;&#x884C;&#x66F4;&#x65B0;:</p>
<pre><code class="language-bash">poetry update
poetry update pandas</code></pre>
<p>&#x9664;&#x6B64;&#x4E4B;&#x5916;<code>poetry update</code>&#x7684;&#x5BE6;&#x73FE;&#x6D41;&#x7A0B;&#x548C;&#x4E0A;&#x4E00;&#x90E8;&#x5206;&#x4ECB;&#x7D39;&#x7684;<code>poetry lock</code>&#x6D41;&#x7A0B;&#x662F;&#x4E00;&#x6A23;&#x7684;&#xFF0C;<code>poetry update</code>&#x540C;&#x6A23;&#x4E5F;&#x6703;&#x6839;&#x64DA;<code>pyproject.toml</code>&#x4F86;&#x7522;&#x751F;&#x5C0D;&#x61C9;&#x7684;<code>poetry.lock</code>&#xFF0C;&#x4E0D;&#x904E;&#x6703;&#x628A;&#x5F8C;&#x7E8C;&#x7684;<code>poetry install</code>&#x4E5F;&#x4E00;&#x4F75;&#x57F7;&#x884C;&#x3002;</p>
<p>&#x5C07;<code>pandas</code>&#x7248;&#x672C;&#x6539;&#x56DE;^2.1.0&#xFF0C;&#x4E26;&#x57F7;&#x884C;<code>poetry update</code>:</p>
<pre><code class="language-toml">[tool.poetry.dependencies]
python = &quot;3.10.10&quot;
pandas = &quot;^2.1.0&quot;</code></pre>
<p>&#x6703;&#x5F97;&#x5230;&#x4EE5;&#x4E0B;&#x7D50;&#x679C;:</p>
<pre><code class="language-bash">Updating dependencies
Resolving dependencies...

Package operations: 0 installs, 1 update, 0 removals

  &#x2022; Updating pandas (2.0.0 -&gt; 2.1.0)

Writing lock file</code></pre>
<p>&#x66F4;&#x65B0;<code>poetry.lock</code>&#x7684;&#x540C;&#x6642;&#x4E5F;&#x6703;&#x5957;&#x7528;&#x5230;&#x865B;&#x64EC;&#x74B0;&#x5883;:</p>
<pre><code class="language-bash">&gt;&gt;&gt; import pandas as pd
&gt;&gt;&gt; pd.__version__
&apos;2.1.0&apos;</code></pre>
<h3 id="poetry-show">poetry show</h3>
<p><code>poetry show</code>&#x7684;&#x4F5C;&#x7528;&#x8DDF;<code>pip list</code>&#x3001;<code>conda list</code>&#x4E00;&#x6A23;&#xFF0C;&#x90FD;&#x662F;&#x5217;&#x51FA;&#x6240;&#x5B89;&#x88DD;&#x7684;&#x5957;&#x4EF6;&#xFF0C;&#x76F4;&#x63A5;&#x4F7F;&#x7528;&#x7684;&#x7D50;&#x679C;&#x5982;&#x4E0B;:</p>
<pre><code class="language-bash">numpy           1.25.2       Fundamental package for array computing in Python
pandas          2.1.0        Powerful data structures for data analysis, time series, and stat...  
python-dateutil 2.8.2        Extensions to the standard Python datetime module
pytz            2023.3.post1 World timezone definitions, modern and historical
six             1.16.0       Python 2 and 3 compatibility utilities
tzdata          2023.3       Provider of IANA time zone data</code></pre>
<p>&#x9664;&#x6B64;&#x4E4B;&#x5916;&#x9084;&#x6709;&#x4E00;&#x500B;&#x7279;&#x5225;&#x7684;&#x529F;&#x80FD;&#xFF0C;&#x5C31;&#x662F;&#x5217;&#x51FA;&#x5957;&#x4EF6;&#x7684;&#x6A39;&#x72C0;&#x7D50;&#x69CB;&#xFF0C;&#x4F7F;&#x7528;&#x65B9;&#x6CD5;&#x662F;&#x76F4;&#x63A5;&#x5728;<code>poetry show</code>&#x5F8C;&#x9762;&#x52A0;&#x4E0A;<code>--tree</code>&#x53C3;&#x6578;&#xFF0C;&#x7528;&#x9019;&#x7A2E;&#x65B9;&#x5F0F;&#x53EF;&#x4EE5;&#x986F;&#x793A;&#x4E3B;&#x8981;&#x5957;&#x4EF6;&#x548C;&#x4F9D;&#x8CF4;&#x5957;&#x4EF6;&#x7684;&#x95DC;&#x4FC2;&#x8207;&#x968E;&#x7D1A;&#xFF0C;&#x7D50;&#x679C;&#x5982;&#x4E0B;:</p>
<pre><code class="language-bash">pandas 2.1.0 Powerful data structures for data analysis, time series, and statistics
&#x251C;&#x2500;&#x2500; numpy &gt;=1.22.4
&#x251C;&#x2500;&#x2500; numpy &gt;=1.23.2
&#x251C;&#x2500;&#x2500; python-dateutil &gt;=2.8.2
&#x2502;   &#x2514;&#x2500;&#x2500; six &gt;=1.5
&#x251C;&#x2500;&#x2500; pytz &gt;=2020.1
&#x2514;&#x2500;&#x2500; tzdata &gt;=2022.1</code></pre>
<p>&#x4E5F;&#x53EF;&#x4EE5;&#x5217;&#x51FA;&#x6307;&#x5B9A;&#x7684;&#x5957;&#x4EF6;&#xFF0C;&#x5982;&#x4E0B;:</p>
<pre><code class="language-bash">poetry show pandas
poetry show pandas --tree</code></pre>
<h3 id="poetry-remove">poetry remove</h3>
<p><code>poetry remove</code>&#x7684;&#x4F5C;&#x7528;&#x5982;&#x540C;&#x5B57;&#x9762;&#x4E0A;&#x4E00;&#x6A23;&#x662F;&#x7528;&#x4F86;&#x79FB;&#x9664;&#x4E0D;&#x8981;&#x7684;&#x5957;&#x4EF6;&#xFF0C;&#x5728;&#x6307;&#x4EE4;&#x5F8C;&#x9762;&#x8981;&#x52A0;&#x4E0A;&#x8981;&#x79FB;&#x9664;&#x7684;&#x5957;&#x4EF6;&#x540D;&#x7A31;:</p>
<pre><code class="language-bash">poetry remove pandas</code></pre>
<p>&#x5F9E;&#x8F38;&#x51FA;&#x7D50;&#x679C;&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x9664;&#x4E86;&#x628A;pandas&#x79FB;&#x9664;&#x4EE5;&#x5916;&#xFF0C;&#x4E5F;&#x5C07;&#x4F9D;&#x8CF4;&#x7684;&#x5957;&#x4EF6;&#x4E00;&#x4F75;&#x79FB;&#x9664;&#x4E86;:</p>
<pre><code class="language-bash">Updating dependencies
Resolving dependencies...

Package operations: 0 installs, 0 updates, 6 removals

  &#x2022; Removing numpy (1.25.2)
  &#x2022; Removing pandas (2.0.0)
  &#x2022; Removing python-dateutil (2.8.2)
  &#x2022; Removing pytz (2023.3.post1)
  &#x2022; Removing six (1.16.0)
  &#x2022; Removing tzdata (2023.3)

Writing lock file</code></pre>
<h3 id="group">group</h3>
<p>&#x5728;python&#x6709;&#x4E00;&#x4E9B;&#x5957;&#x4EF6;&#x53EF;&#x80FD;&#x53EA;&#x6703;&#x5728;&#x958B;&#x767C;&#x7684;&#x6642;&#x5019;&#x7528;&#x5230;&#xFF0C;&#x50CF;&#x662F;code formatter&#x76F8;&#x95DC;&#x7684;&#x5957;&#x4EF6;<code>black</code>&#x3001;<code>yapf</code>&#xFF0C;&#x6216;&#x662F;&#x8CA0;&#x8CAC;&#x6E2C;&#x8A66;&#x7684;&#x5957;&#x4EF6;<code>pytest</code>&#xFF0C;&#x9019;&#x4E9B;&#x90FD;&#x53EA;&#x6703;&#x5728;&#x958B;&#x767C;&#x7684;&#x6642;&#x5019;&#x4F7F;&#x7528;&#x5230;&#xFF0C;&#x4F60;&#x4E0D;&#x6703;&#x5E0C;&#x671B;&#x88AB;&#x5305;&#x5728;&#x90E8;&#x7F72;&#x74B0;&#x5883;&#x88E1;&#x9762;&#xFF0C;&#x7121;&#x8B02;&#x7684;&#x589E;&#x52A0;&#x5927;&#x5C0F;&#x4F7F;&#x5F97;&#x90E8;&#x7F72;&#x74B0;&#x5883;&#x904E;&#x65BC;&#x81C3;&#x816B;&#x3002;</p>
<p>&#x6240;&#x4EE5;&#x5728;&#x5B89;&#x88DD;&#x5957;&#x4EF6;&#x7684;&#x6642;&#x5019;&#x53EF;&#x4EE5;&#x52A0;&#x4E0A;<code>--group</code>&#x6216;&#x662F;<code>-G</code>&#x4F86;&#x5340;&#x5206;&#x958B;&#x767C;&#x74B0;&#x5883;&#x6216;&#x662F;&#x6E2C;&#x8A66;&#x74B0;&#x5883;&#x6240;&#x9700;&#x5B89;&#x88DD;&#x7684;&#x5957;&#x4EF6;&#xFF0C;<s>&#x9810;&#x8A2D;&#x4E3B;&#x74B0;&#x5883;&#x7684;group&#x540D;&#x7A31;&#x662F;<code>main</code></s>&#x76EE;&#x524D;&#x65B0;&#x7684;&#x7248;&#x672C;&#x6539;&#x6210;&#x7528;group&#x4F86;&#x5340;&#x5206;&#xFF0C;&#x9810;&#x8A2D;&#x7684;&#x4E3B;&#x74B0;&#x5883;&#x70BA;<code>tool.poetry.dependencies</code>:</p>
<pre><code class="language-bash">poetry add black --group dev
poetry add pytest --group test
poetry add pandas --group main</code></pre>
<p>&#x5982;&#x679C;&#x662F;&#x7B2C;&#x4E00;&#x6B21;&#x52A0;&#x4E0A;<code>group</code>&#x4F86;&#x5B89;&#x88DD;&#x5957;&#x4EF6;&#xFF0C;&#x6253;&#x958B;<code>pyproject.toml</code>&#x6703;&#x767C;&#x73FE;&#x9664;&#x4E86;<code>tool.poetry.dependencies</code>&#x4EE5;&#x5916;&#x591A;&#x4E86;&#x4E00;&#x6BB5;&#xFF0C;&#x9019;&#x662F;&#x5728;<code>group</code>&#x74B0;&#x5883;&#x4E2D;&#x6240;&#x9700;&#x8981;&#x5B89;&#x88DD;&#x5957;&#x4EF6;&#xFF0C;&#x5982;&#x4E0B;:</p>
<pre><code>[tool.poetry.group.yourgroupname.dependencies]
package_name = &quot;^version&quot;</code></pre>
<p>&#x524D;&#x9762;&#x5728;&#x4ECB;&#x7D39;&#x628A;<code>poetry.lock</code>&#x7684;&#x66F4;&#x6539;&#x5BEB;&#x5165;&#x5C0D;&#x61C9;&#x865B;&#x64EC;&#x74B0;&#x5883;&#x6703;&#x7528;<code>poetry install</code>&#x9019;&#x500B;&#x6307;&#x4EE4;&#xFF0C;&#x5728;<strong>&#x9084;&#x6C92;&#x6709;&#x5EFA;&#x7ACB;</strong>&#x865B;&#x64EC;&#x74B0;&#x5883;&#x7684;&#x6642;&#x5019;&#xFF0C;&#x8981;&#x5B89;&#x88DD;&#x4E0D;&#x540C;&#x7684;<code>group</code>&#x7684;&#x8A71;&#xFF0C;&#x53EF;&#x4EE5;&#x5728;&#x5F8C;&#x9762;&#x6DFB;&#x52A0;<code>--without</code>&#x3001;<code>--with</code>&#x6216;<code>--only</code>&#xFF1B;&#x5982;&#x679C;<strong>&#x5DF2;&#x7D93;&#x5EFA;&#x7ACB;</strong>&#x865B;&#x64EC;&#x74B0;&#x5883;&#x7684;&#x6642;&#x5019;&#xFF0C;&#x53EF;&#x4EE5;&#x900F;&#x904E;<code>--sync</code>&#x9078;&#x9805;&#x540C;&#x6B65;&#x74B0;&#x5883;&#x4E26;&#x78BA;&#x4FDD;&#x8207;<code>poetry.lock</code>&#x5339;&#x914D; :</p>
<pre><code class="language-bash"># &#x6392;&#x9664;test&#x548C;docs group
poetry install --without test,docs
# &#x9078;&#x64C7;test group
poetry install --with test
# &#x50C5;&#x5B89;&#x88DD;test group
poetry install --only test

# sync &#x4E00;&#x6A23;&#x53EF;&#x4EE5;&#x5957;&#x7528;with&#x3001;without&#x3001;only
poetry install --without test --sync
poetry install --with test --sync
poetry install --only test --sync</code></pre>
<div class="kg-card kg-callout-card kg-callout-card-red"><div class="kg-callout-emoji">&#x1F4A1;</div><div class="kg-callout-text">&#x900F;&#x904E;--with&#x548C;--only&#x4F86;&#x5B89;&#x88DD;&#x9664;&#x4E86;&#x6703;&#x5B89;&#x88DD;&#x5728;&#x6240;&#x9078;&#x7684;group&#x4E2D;&#x7684;&#x5957;&#x4EF6;&#x5916;(&#x4E5F;&#x5C31;&#x662F;[tool.poetry.group.yourgroupname.dependencies]&#x6240;&#x5217;&#x7684;&#x5957;&#x4EF6;&#x5916;)&#xFF0C;&#x5169;&#x8005;&#x7684;&#x5DEE;&#x5225;&#x70BA;&#x662F;&#x5426;&#x6703;&#x5B89;&#x88DD;tool.poetry.dependencies&#x4E2D;&#x6240;&#x5217;&#x7684;&#x5957;&#x4EF6;&#x3002;</div></div>
<p>&#x5982;&#x679C;&#x60F3;&#x5C07;&#x74B0;&#x5883;&#x9084;&#x539F;&#x6210;&#x6C92;&#x6709;&#x5B89;&#x88DD;&#x5957;&#x4EF6;&#x7684;&#x72C0;&#x614B;&#xFF0C;&#x53EF;&#x4EE5;&#x900F;&#x904E;&#x4EE5;&#x4E0B;&#x6307;&#x4EE4;&#xFF0C;&#x74B0;&#x5883;&#x5C31;&#x53EA;&#x6703;&#x5269;&#x4E0B;python&#x672C;&#x8EAB;&#x7684;&#x57FA;&#x790E;&#x5957;&#x4EF6;:</p>
<pre><code class="language-bash">poetry install --only-root --sync</code></pre>
<p>&#x5177;&#x9AD4;&#x7684;&#x6307;&#x4EE4;&#x53EF;&#x4EE5;&#x53C3;&#x8003;<a href="https://python-poetry.org/docs/cli/?ref=ghost.augustushsu.com#install">&#x5B98;&#x65B9;&#x6587;&#x4EF6;</a>&#x7684;&#x8AAA;&#x660E;&#x3002;</p>
<h3 id="poetry-export">poetry export</h3>
<p>&#x96D6;&#x7136;&#x8AAA;&#x5DF2;&#x7D93;&#x4F7F;&#x7528;Poetry&#x4F86;&#x7BA1;&#x7406;python&#x5957;&#x4EF6;&#xFF0C;&#x4F46;&#x9084;&#x662F;&#x6709;&#x53EF;&#x80FD;&#x6703;&#x9700;&#x8981;&#x8F49;&#x5230;&#x5176;&#x4ED6;&#x6C92;&#x6709;Poetry&#x7684;&#x74B0;&#x5883;&#x4F7F;&#x7528;&#xFF0C;&#x90A3;&#x5C31;&#x9700;&#x8981;&#x5C07;&#x5B89;&#x88DD;&#x7684;&#x5957;&#x4EF6;&#x532F;&#x51FA;&#x6210;<code>requirements.txt</code>&#xFF0C;&#x518D;&#x5230;&#x5176;&#x4ED6;&#x74B0;&#x5883;&#x7528;<code>pip install</code>&#x4F86;&#x5B89;&#x88DD;&#xFF0C;&#x9019;&#x6642;&#x5019;&#x5C31;&#x9700;&#x8981;<code>poetry export</code>:</p>
<pre><code class="language-bash">poetry export -f requirements.txt -o requirements.txt
</code></pre>
<div class="kg-card kg-callout-card kg-callout-card-grey"><div class="kg-callout-emoji">&#x1F4A1;</div><div class="kg-callout-text">&#x8981;&#x6CE8;&#x610F;&#x7684;&#x662F;&#x7528;&#x9019;&#x6307;&#x4EE4;&#x7522;&#x751F;&#x51FA;&#x4F86;&#x7684;requirements.txt<b><strong style="white-space: pre-wrap;">&#x9810;&#x8A2D;</strong></b>&#x53EA;&#x6703;&#x8F38;&#x51FA;pyproject.toml&#x4E2D;&#x7684;[tool.poetry.dependencies]&#x5340;&#x584A;&#x5167;&#x7684;&#x5957;&#x4EF6;&#x3002;</div></div>
<p>&#x5982;&#x679C;&#x8981;&#x6307;&#x5B9A;&#x8F38;&#x51FA;&#x7684;<code>group</code>&#x548C;&#x524D;&#x9762;&#x7684;<code>poetry install</code>&#x4E00;&#x6A23;&#xFF0C;&#x8981;&#x4F7F;&#x7528;<code>--with</code>&#x3001;<code>--without</code>&#x6216;&#x662F;<code>--only</code>&#x4F86;&#x6307;&#x5B9A;&#x8981;&#x4F7F;&#x7528;&#x7684;<code>group</code>&#xFF0C;&#x898F;&#x5247;&#x548C;&#x524D;&#x9762;&#x4ECB;&#x7D39;&#x7684;&#x4E00;&#x6A23;:</p>
<pre><code class="language-bash">poetry export -f requirements.txt -o requirements.txt --only test,docs</code></pre>
<p>&#x8F38;&#x51FA;&#x7684;<code>requirements.txt</code>&#x9810;&#x8A2D;&#x6703;&#x6709;hash&#x503C;&#xFF0C;&#x7528;<code>pip install</code>&#x5B89;&#x88DD;&#x6703;&#x6AA2;&#x67E5;&#x9019;&#x4E9B;hash:</p>
<pre><code class="language-txt">pandas==2.1.0 ; python_full_version &gt;= &quot;3.10.11&quot; and python_full_version &lt; &quot;4.0.0&quot; \
    --hash=sha256:0164b85937707ec7f70b34a6c3a578dbf0f50787f910f21ca3b26a7fd3363437 \
# &#x4E0B;&#x7565;</code></pre>
<p>&#x5982;&#x679C;&#x4E0D;&#x8981;&#x6709;hash&#xFF0C;&#x52A0;&#x4E0A;<code>--without-hashes</code>&#x5C31;&#x884C;:</p>
<pre><code class="language-bash">poetry export -f requirements.txt -o requirements.txt --without-hashes
</code></pre>
<p>&#x5982;&#x679C;&#x8981;&#x5728;Docker&#x4E0A;&#x4F7F;&#x7528;Poetry&#x4F86;&#x5B89;&#x88DD;&#x5C08;&#x6848;&#x5167;&#x4F7F;&#x7528;&#x7684;&#x5957;&#x4EF6;&#xFF0C;&#x6709;&#x4E00;&#x7BC7;<a href="https://medium.com/@albertazzir/blazing-fast-python-docker-builds-with-poetry-a78a66f5aed0?ref=ghost.augustushsu.com">&#x6587;&#x7AE0;</a>&#x8A73;&#x7D30;&#x7684;&#x4ECB;&#x7D39;&#x5982;&#x4F55;&#x7528;Docker&#x900F;&#x904E;Poetry&#x5B89;&#x88DD;&#x5957;&#x4EF6;&#x4E14;&#x7522;&#x751F;&#x6700;&#x5C0F;&#x5316;&#x7684;Image&#x3002;</p>
<h2 id="%E7%B8%BD%E7%B5%90%E5%B8%B8%E7%94%A8%E6%8C%87%E4%BB%A4">&#x7E3D;&#x7D50;&#x5E38;&#x7528;&#x6307;&#x4EE4;</h2>
<ol><li><code>poetry init</code>/<code>poetry new &lt;&#x5C08;&#x6848;&#x8DEF;&#x5F91;&gt;</code> : &#x521D;&#x59CB;&#x5316;&#x5C08;&#x6848;</li><li><code>poetry env use &lt;python&#x8DEF;&#x5F91;&gt;</code> : &#x5EFA;&#x7ACB;&#x74B0;&#x5883;&#x7528;</li><li><code>poetry shell</code> : &#x9032;&#x5165;&#x5EFA;&#x7ACB;&#x7684;&#x865B;&#x64EC;&#x74B0;&#x5883;</li><li><code>poetry add</code> : &#x5B89;&#x88DD;&#x5957;&#x4EF6;</li><li><code>poetry lock</code> : &#x6839;&#x64DA;<code>pyproject.toml</code>&#x66F4;&#x65B0;<code>poetry .lock</code></li><li><code>poetry install</code> : &#x6839;&#x64DA;<code>poetry.lock</code>&#x66F4;&#x65B0;&#x865B;&#x64EC;&#x74B0;&#x5883;</li><li><code>poetry update</code> : &#x66F4;&#x65B0;&#x5957;&#x4EF6;</li><li><code>poetry show</code> : &#x5217;&#x51FA;&#x5B89;&#x88DD;&#x7684;&#x5957;&#x4EF6;</li><li><code>poetry remove &lt;&#x5957;&#x4EF6;&#x540D;&#x7A31;&gt;</code> : &#x79FB;&#x9664;&#x6307;&#x5B9A;&#x5957;&#x4EF6;</li><li><code>poetry export</code>:&#x532F;&#x51FA;&#x5B89;&#x88DD;&#x7684;&#x5957;&#x4EF6;</li></ol>]]></content:encoded></item><item><title><![CDATA[Ghost Blog Note 01]]></title><description><![CDATA[安裝Ghost Blog過程的筆記。]]></description><link>https://ghost.augustushsu.com/ghost-blog-note-01/</link><guid isPermaLink="false">64e1baea08c8f60331e9cc5d</guid><category><![CDATA[Ghost-Blog-Note]]></category><dc:creator><![CDATA[AugustusHsu]]></dc:creator><pubDate>Sun, 17 Sep 2023 12:00:06 GMT</pubDate><media:content url="https://ghost.augustushsu.com/content/images/2023/09/ghost-blog-note01-cover-1.png" medium="image"/><content:encoded><![CDATA[<h1 id="%E5%AE%89%E8%A3%9D%E7%B4%80%E9%8C%84">&#x5B89;&#x88DD;&#x7D00;&#x9304;</h1><img src="https://ghost.augustushsu.com/content/images/2023/09/ghost-blog-note01-cover-1.png" alt="Ghost Blog Note 01"><p>&#x64B0;&#x5BEB;&#x90E8;&#x843D;&#x683C;&#x662F;&#x70BA;&#x4E86;&#x8A18;&#x9304;&#x4E00;&#x4E9B;&#x65E5;&#x5E38;&#x6216;&#x8005;&#x8A18;&#x9304;&#x4E00;&#x4E9B;&#x5B78;&#x7FD2;&#x7B46;&#x8A18;&#xFF0C;&#x6211;&#x4E00;&#x76F4;&#x8A8D;&#x70BA;&#x662F;&#x4E00;&#x4E9B;&#x5F88;&#x9177;&#x7684;&#x884C;&#x70BA;&#xFF0C;&#x4E0D;&#x904E;&#x56E0;&#x70BA;&#x61F6;&#x60F0;&#x7B49;&#x7B49;&#x539F;&#x56E0;&#x7E3D;&#x662F;&#x66F4;&#x65B0;&#x7684;&#x5F88;&#x6162;&#x3001;&#x5F88;&#x4F5B;&#x6027;&#x3002;</p><p>&#x5F9E;2019&#x5E74;&#x958B;&#x59CB;&#xFF0C;&#x6211;&#x4F7F;&#x7528;hexo&#x5229;&#x7528;github&#x7684;&#x9801;&#x9762;&#x529F;&#x80FD;&#x5728;github.io&#x4E0A;&#x5EFA;&#x7ACB;&#x4E86;&#x90E8;&#x843D;&#x683C;&#xFF0C;&#x5BEB;&#x4E86;&#x4E00;&#x4E9B;&#x5B78;&#x7FD2;&#x3001;&#x7814;&#x7A76;&#x6280;&#x8853;&#x7684;&#x6587;&#x7AE0;&#xFF0C;&#x8352;&#x5EE2;&#x7684;&#x5F88;&#x5927;&#x4E00;&#x500B;&#x539F;&#x56E0;&#x662F;hexo&#x7684;&#x4E00;&#x4E9B;&#x8A2D;&#x7F6E;&#x6709;&#x9EDE;&#x8907;&#x96DC;&#xFF0C;&#x9700;&#x8981;&#x8655;&#x7406;&#x4E3B;&#x984C;&#x3001;&#x63D2;&#x4EF6;&#x3001;&#x4F48;&#x5C40;&#x7B49;&#x7B49;&#x8A2D;&#x7F6E;&#xFF0C;&#x800C;&#x4E14;&#x6211;&#x672C;&#x8EAB;&#x4E5F;&#x4E0D;&#x719F;&#x6089; Node.js&#xFF0C;&#x70BA;&#x4E86;&#x7DAD;&#x8B77;&#x6216;&#x5347;&#x7D1A;&#x9019;&#x4E9B;&#x6709;&#x9EDE;&#x96E3;&#x5EA6;&#xFF0C;&#x53E6;&#x5916;&#x7DE8;&#x8F2F;&#x3001;&#x767C;&#x5E03;&#x7684;&#x529F;&#x80FD;&#x56E0;&#x70BA;&#x4E0D;&#x662F;&#x6240;&#x898B;&#x5373;&#x6240;&#x5F97;&#x7684;&#x65B9;&#x5F0F;&#xFF0C;&#x901A;&#x5E38;&#x53EF;&#x80FD;&#x9700;&#x8981;&#x82B1;&#x4E00;&#x500B;&#x6392;&#x7248;&#x4E82;&#x6389;&#x6703;&#x4E00;&#x5806;&#x6642;&#x9593;&#x53BB;&#x627E;&#x5230;&#x554F;&#x984C;&#xFF0C;&#x5F8C;&#x4F86;&#x5C31;&#x627E;&#x5230;&#x4E86;Ghost Blog&#x9019;&#x500B;&#x53EF;&#x4EE5;&#x9078;&#x64C7;&#x5728;&#x5E73;&#x53F0;&#x4E0A;&#x958B;&#x8CEC;&#x865F;&#x6216;&#x8005;&#x81EA;&#x67B6;&#x7684;&#x90E8;&#x843D;&#x683C;&#x3002;</p><p>&#x9019;&#x500B;&#x90E8;&#x843D;&#x683C;&#x662F;&#x5B89;&#x88DD;&#x5728;AWS&#x63D0;&#x4F9B;&#x7684;lightsail&#x670D;&#x52D9;&#x4E0A;&#xFF0C;&#x5B89;&#x88DD;&#x7684;&#x65B9;&#x6CD5;&#x5F88;&#x7C21;&#x55AE;&#x800C;&#x4E14;&#x5728;<a href="https://docs.aws.amazon.com/lightsail/latest/userguide/amazon-lightsail-quick-start-guide-ghost.html?ref=ghost.augustushsu.com">&#x7DB2;&#x4E0A;</a>&#x4E5F;&#x6709;&#x6559;&#x5B78;&#xFF0C;&#x9019;&#x88E1;&#x5C31;&#x5148;&#x8DF3;&#x904E;&#x4E86;&#xFF0C;&#x672C;&#x6587;&#x4E3B;&#x8981;&#x8A18;&#x9304;&#x91DD;&#x5C0D;&#x4E3B;&#x984C;&#x53BB;&#x66F4;&#x6539;&#x4EC0;&#x9EBC;&#x4E86;&#x8A2D;&#x7F6E;&#x3001;&#x6216;&#x8005;&#x6DFB;&#x52A0;&#x4E86;&#x4EC0;&#x9EBC;&#x70BA;&#x4E3B;&#x3002;</p><h2 id="%E6%9B%B4%E6%96%B0%E5%B9%BD%E9%9D%88">&#x66F4;&#x65B0;&#x5E7D;&#x9748;</h2><p>&#x9032;&#x5165;ghost&#x8CC7;&#x6599;&#x593E;&#xFF0C;&#x66F4;&#x65B0;&#x5F8C;&#x66F4;&#x6539;&#x6B0A;&#x9650;&#xFF1A;</p><pre><code class="language-bash">cd /opt/bitnami/ghost
sudo su ghost -c &quot;ghost update&quot;

sudo chown ghost:bitnami -R /opt/bitnami/ghost
sudo chmod 640 /opt/bitnami/ghost/config.production.json</code></pre><p>&#x66F4;&#x65B0;&#x5F8C;<code>config.production.json</code>&#x53EF;&#x80FD;&#x6703;&#x6539;&#x8B8A;&#x53EF;&#x4EE5;&#x53BB;&#x67E5;&#x770B;&#x662F;&#x5426;&#x6709;&#x88AB;&#x8B8A;&#x66F4;&#xFF0C;&#x4E3B;&#x8981;&#x53EF;&#x80FD;&#x88AB;&#x8B8A;&#x66F4;&#x7684;&#x9078;&#x9805;&#x5982;&#x4E0B;&#xFF1A;</p><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/08/image-11.png" class="kg-image" alt="Ghost Blog Note 01" loading="lazy" width="659" height="174" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/08/image-11.png 600w, https://ghost.augustushsu.com/content/images/2023/08/image-11.png 659w"></figure><p>&#x6539;&#x56DE;&#x4F86;&#x5F8C;&#x9700;&#x8981;&#x91CD;&#x555F;ghost&#xFF1A;</p><pre><code class="language-bash">sudo su ghost -c &quot;ghost restart&quot;</code></pre><h2 id="%E5%82%99%E4%BB%BD%E8%A8%AD%E7%BD%AE">&#x5099;&#x4EFD;&#x8A2D;&#x7F6E;</h2><p>&#x4E4B;&#x524D;&#x5728;&#x5347;&#x7D1A;Ghost Blog&#x7684;&#x6642;&#x5019;&#xFF0C;&#x9047;&#x5230;&#x56E0;&#x70BA;&#x6253;&#x932F;&#x6307;&#x4EE4;&#x5C0E;&#x81F4;&#x6574;&#x500B;&#x90E8;&#x843D;&#x683C;&#x958B;&#x4E0D;&#x8D77;&#x4F86;&#xFF0C;&#x5F8C;&#x4F86;&#x76F4;&#x63A5;&#x60F3;&#x8FA6;&#x6CD5;&#x53D6;&#x51FA;&#x524D;&#x4E00;&#x6BB5;&#x6642;&#x9593;&#x6162;&#x6162;&#x532F;&#x51FA;&#x7684;&#x8CC7;&#x6599;&#xFF0C;&#x518D;&#x9084;&#x539F;&#x5230;&#x65B0;&#x7684;&#x670D;&#x52D9;&#x5668;&#x4E0A;&#xFF0C;&#x6240;&#x4EE5;&#x5728;&#x5C0D;&#x670D;&#x52D9;&#x5668;&#x9032;&#x884C;&#x64CD;&#x4F5C;&#x7684;&#x6642;&#x5019;&#x9032;&#x884C;&#x5099;&#x4EFD;&#x6216;&#x5B9A;&#x671F;&#x5099;&#x4EFD;&#x662F;&#x4E00;&#x4EF6;&#x5F88;&#x91CD;&#x8981;&#x7684;&#x4E8B;&#x60C5;&#xFF0C;&#x5728;&#x9019;&#x53F0;&#x670D;&#x52D9;&#x5668;&#x4E0A;&#x6211;&#x6240;&#x4F7F;&#x7528;&#x7684;&#x65B9;&#x5F0F;&#x662F;Amazon Lightsail&#x7684;Sanpshots&#x4F86;&#x9032;&#x884C;&#x5099;&#x4EFD;&#xFF0C;&#x4ED6;&#x53EF;&#x4EE5;&#x624B;&#x52D5;&#x9032;&#x884C;&#x5099;&#x4EFD;&#x3001;&#x4E5F;&#x53EF;&#x4EE5;&#x5B9A;&#x671F;&#x57F7;&#x884C;&#x5099;&#x4EFD;&#x7684;&#x52D5;&#x4F5C;&#xFF0C;&#x6574;&#x9AD4;&#x4F86;&#x8AAA;&#x6709;&#x4E00;&#x500B;&#x5F88;&#x65B9;&#x4FBF;&#x7684;&#x529F;&#x80FD;&#x3002;</p><h3 id="%E5%BF%AB%E7%85%A7">&#x5FEB;&#x7167;</h3><p>&#x9032;&#x5165; Amazon Lightsai &#x7684;&#x9801;&#x9762;&#xFF0C;&#x770B;&#x5230;&#x5927;&#x91CF;&#x5BE6;&#x4F8B;&#x4E2D;&#x60A8;&#x8981;&#x5099;&#x4EFD;&#x7684;&#x6A5F;&#x5668;&#xFF0C;&#x7136;&#x5F8C;&#x9078;&#x64C7;&#x5FEB;&#x7167;&#xFF0C;&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x4EE5;&#x4E0B;&#x756B;&#x9762;&#xFF1A;</p><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/09/image-7.png" class="kg-image" alt="Ghost Blog Note 01" loading="lazy" width="907" height="475" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/09/image-7.png 600w, https://ghost.augustushsu.com/content/images/2023/09/image-7.png 907w" sizes="(min-width: 720px) 720px"></figure><p>&#x53EF;&#x4EE5;&#x76F4;&#x63A5;<code>Create snapshot</code>:</p><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/09/image-8.png" class="kg-image" alt="Ghost Blog Note 01" loading="lazy" width="941" height="252" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/09/image-8.png 600w, https://ghost.augustushsu.com/content/images/2023/09/image-8.png 941w" sizes="(min-width: 720px) 720px"></figure><p>&#x6216;&#x662F;&#x958B;&#x555F;&#x4E0B;&#x9762;&#x7684;Automatic snapshots&#xFF0C;Change snapshot time&#x4F86;&#x9078;&#x64C7;&#x5099;&#x4EFD;&#x6642;&#x9593;:</p><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/09/image-9.png" class="kg-image" alt="Ghost Blog Note 01" loading="lazy" width="936" height="400" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/09/image-9.png 600w, https://ghost.augustushsu.com/content/images/2023/09/image-9.png 936w" sizes="(min-width: 720px) 720px"></figure><h2 id="mail%E8%A8%AD%E5%AE%9A">mail&#x8A2D;&#x5B9A;</h2><p>&#x8981;&#x8B93;&#x5176;&#x4ED6;&#x5C0D;&#x4F60;&#x7684;Ghost&#x90E8;&#x843D;&#x683C;&#x6709;&#x8208;&#x8DA3;&#x7684;&#x4EBA;&#x53EF;&#x4EE5;&#x9032;&#x884C;&#x8A55;&#x8AD6;&#x3001;&#x901A;&#x77E5;&#x8A02;&#x95B1;&#x8005;&#x767C;&#x4E86;&#x65B0;&#x6587;&#x7AE0;&#x7B49;&#x7B49;&#x64CD;&#x4F5C;&#xFF0C;&#x6216;&#x662F;&#x4F5C;&#x8005;&#x9700;&#x8981;&#x5C0D;&#x5BC6;&#x78BC;&#x9032;&#x884C;&#x91CD;&#x88FD;&#x7B49;&#x7B49;&#x90FD;&#x9700;&#x8981;&#x4F7F;&#x7528;&#x5230;&#x90F5;&#x4EF6;&#x4F86;&#x901A;&#x77E5;&#x3002;&#x9019;&#x88E1;&#x4F7F;&#x7528;&#x4E86;SMTP&#x7684;&#x65B9;&#x5F0F;&#x9032;&#x884C;&#x8A2D;&#x5B9A;&#xFF0C;SMTP&#x7684;&#x670D;&#x52D9;&#x5247;&#x662F;&#x9078;&#x64C7;&#x4E86;Mailgun&#x4F86;&#x767C;&#x9001;&#x90F5;&#x4EF6;&#x3002;</p><h3 id="mailgun%E8%A8%AD%E5%AE%9A">Mailgun&#x8A2D;&#x5B9A;</h3><p>&#x9032;&#x5165;Mailgun&#x7684;&#x63A7;&#x5236;&#x53F0;&#x5728;&#x53F3;&#x4E0A;&#x89D2;&#x9EDE;&#x9078;<code>Add New Domain</code>&#x65B0;&#x589E;&#x4E00;&#x500B;&#x7DB2;&#x57DF;:</p><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/09/2023-09-04-140727.png" class="kg-image" alt="Ghost Blog Note 01" loading="lazy" width="1547" height="752" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/09/2023-09-04-140727.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2023/09/2023-09-04-140727.png 1000w, https://ghost.augustushsu.com/content/images/2023/09/2023-09-04-140727.png 1547w" sizes="(min-width: 720px) 720px"></figure><p>&#x6309;&#x7167;&#x8AAA;&#x660E;&#x586B;&#x5165;&#x4F60;&#x7684;&#x7DB2;&#x57DF;&#x548C;&#x9078;&#x64C7;&#x4F7F;&#x7528;&#x7684;&#x4F3A;&#x670D;&#x5668;:</p><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/09/image-4.png" class="kg-image" alt="Ghost Blog Note 01" loading="lazy" width="1222" height="473" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/09/image-4.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2023/09/image-4.png 1000w, https://ghost.augustushsu.com/content/images/2023/09/image-4.png 1222w" sizes="(min-width: 720px) 720px"></figure><p>&#x63A5;&#x4E0B;&#x4F86;&#x8981;&#x53BB;&#x7BA1;&#x7406;&#x4F60;&#x7DB2;&#x57DF;&#x7684;DNS&#x670D;&#x52D9;&#x5546;&#x90A3;&#x88CF;&#x53BB;&#x8A2D;&#x5B9A;DNS&#x7D00;&#x9304;&#x3001;MX&#x7D00;&#x9304;:</p><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/09/03-1.png" class="kg-image" alt="Ghost Blog Note 01" loading="lazy" width="863" height="1366" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/09/03-1.png 600w, https://ghost.augustushsu.com/content/images/2023/09/03-1.png 863w" sizes="(min-width: 720px) 720px"></figure><p>&#x56E0;&#x70BA;&#x6211;&#x9019;&#x908A;&#x4F7F;&#x7528;&#x7684;&#x662F;Cloudflare&#x5E73;&#x53F0;&#xFF0C;&#x8981;&#x6CE8;&#x610F;&#x6700;&#x5F8C;&#x4E00;&#x500B;CNAME&#x8981;&#x8A18;&#x5F97;&#x5728;Cloudflare&#x4E0A;&#x4E0D;&#x8981;&#x4F7F;&#x7528;&#x5230;proxy&#xFF0C;&#x8981;&#x8A2D;&#x5B9A;&#x6210;DNS only (&#x8981;&#x8B93;&#x6A58;&#x9EC3;&#x8272;&#x5C0F;&#x96F2;&#x8B8A;&#x6210;&#x7070;&#x8272;):</p><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/09/04.jpg" class="kg-image" alt="Ghost Blog Note 01" loading="lazy" width="1080" height="509" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/09/04.jpg 600w, https://ghost.augustushsu.com/content/images/size/w1000/2023/09/04.jpg 1000w, https://ghost.augustushsu.com/content/images/2023/09/04.jpg 1080w" sizes="(min-width: 720px) 720px"></figure><p>&#x90FD;&#x8A2D;&#x5B9A;&#x597D;&#x4E4B;&#x5F8C;&#x53EF;&#x4EE5;&#x9EDE;&#x9078;&#x4E0A;&#x65B9;&#x7684;<code>Verify DNS settings</code>:</p><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/09/05.png" class="kg-image" alt="Ghost Blog Note 01" loading="lazy" width="479" height="84"></figure><p>&#x5982;&#x679C;&#x6C92;&#x6709;&#x554F;&#x984C;&#xFF0C;&#x5728;Status&#x4E0A;&#x6703;&#x986F;&#x793A;Verified&#x6216;&#x662F;Active:</p><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/09/image-5.png" class="kg-image" alt="Ghost Blog Note 01" loading="lazy" width="120" height="424"></figure><p>&#x8A2D;&#x5B9A;&#x597D;&#x4E4B;&#x5F8C;&#x8981;&#x53BB;&#x5DE6;&#x908A;&#x7684;Sending &gt; Domain setting &#xFF0C;&#x63A5;&#x8457;&#x9EDE;&#x9078;SMTP credentials&#xFF0C;&#x8A18;&#x4F4F;&#x9019;&#x88E1;&#x7684;Login&#x540D;&#x7A31;&#x548C;&#x7522;&#x751F;&#x7684;&#x5BC6;&#x78BC;&#xFF0C;&#x5BC6;&#x78BC;&#x5982;&#x679C;&#x5FD8;&#x8A18;&#x4E86;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x9EDE;&#x9078;Reset password&#x4F86;&#x91CD;&#x8A2D;:</p><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/09/06.png" class="kg-image" alt="Ghost Blog Note 01" loading="lazy" width="1273" height="322" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/09/06.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2023/09/06.png 1000w, https://ghost.augustushsu.com/content/images/2023/09/06.png 1273w" sizes="(min-width: 720px) 720px"></figure><p>&#x63A5;&#x8457;&#x5728;&#x540C;&#x500B;&#x9801;&#x9762;&#xFF0C;&#x9EDE;&#x9078;Sending API keys&#xFF0C;&#x518D;&#x9EDE;&#x53F3;&#x4E0A;&#x65B9;&#x7684;<code>Add sending key</code>&#x4F86;&#x65B0;&#x589E;&#xFF0C;&#x8F38;&#x5165;&#x8A72;API Key&#x7684;&#x6558;&#x8FF0;:</p><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/09/07.png" class="kg-image" alt="Ghost Blog Note 01" loading="lazy" width="1300" height="540" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/09/07.png 600w, https://ghost.augustushsu.com/content/images/size/w1000/2023/09/07.png 1000w, https://ghost.augustushsu.com/content/images/2023/09/07.png 1300w" sizes="(min-width: 720px) 720px"></figure><p>&#x5F97;&#x5230;Sending API key&#x4E00;&#x6A23;&#x8A18;&#x9304;&#x4E0B;&#x4F86;&#xFF0C;&#x5982;&#x679C;&#x5FD8;&#x4E86;&#x5247;&#x9700;&#x8981;&#x91CD;&#x65B0;&#x7522;&#x751F;&#xFF0C;&#x4E4B;&#x5F8C;&#x6703;&#x9700;&#x8981;&#x7528;&#x5230;:</p><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/09/08-1.png" class="kg-image" alt="Ghost Blog Note 01" loading="lazy" width="604" height="395" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/09/08-1.png 600w, https://ghost.augustushsu.com/content/images/2023/09/08-1.png 604w"></figure><h3 id="%E5%AF%AB%E5%85%A5mailgun%E8%A8%AD%E5%AE%9A">&#x5BEB;&#x5165;Mailgun&#x8A2D;&#x5B9A;</h3><p>&#x5C07;&#x4E4B;&#x524D;&#x5728;SMTP credentials&#x4E2D;&#x7684;&#x5E33;&#x865F;&#x5BC6;&#x78BC;&#x586B;&#x5165;:</p><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/09/Screenshot-2023-09-04-022720.png" class="kg-image" alt="Ghost Blog Note 01" loading="lazy" width="917" height="361" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/09/Screenshot-2023-09-04-022720.png 600w, https://ghost.augustushsu.com/content/images/2023/09/Screenshot-2023-09-04-022720.png 917w" sizes="(min-width: 720px) 720px"></figure><p>&#x7136;&#x5F8C;&#x8981;&#x5728;&#x5F8C;&#x53F0;&#x7684;Settings &gt; Email newsletter&#x6700;&#x4E0B;&#x65B9;<code>Mailgun configuration</code>&#x9EDE;&#x9078;<code>Expand</code>&#xFF0C;&#x9078;&#x597D;Mailgun region&#x548C;&#x8F38;&#x5165;&#x5728;Mailgun&#x8A3B;&#x518A;&#x7684;domain&#xFF0C;&#x5C07;&#x525B;&#x525B;&#x53D6;&#x5F97;&#x7684;API key&#x8F38;&#x5165;&#x5230;&#x4E0B;&#x65B9;&#x7684;Mailgun Private API key&#x7A7A;&#x683C;&#x8655;:</p><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/09/image-26.png" class="kg-image" alt="Ghost Blog Note 01" loading="lazy" width="937" height="332" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/09/image-26.png 600w, https://ghost.augustushsu.com/content/images/2023/09/image-26.png 937w" sizes="(min-width: 720px) 720px"></figure><h3 id="mailgun%E6%B7%BB%E5%8A%A0%E7%99%BD%E5%90%8D%E5%96%AE">Mailgun&#x6DFB;&#x52A0;&#x767D;&#x540D;&#x55AE;</h3><p>&#x5F04;&#x597D;&#x4E0A;&#x65B9;&#x7684;&#x8A2D;&#x5B9A;&#x5F8C;&#xFF0C;&#x53EF;&#x80FD;&#x6703;&#x767C;&#x73FE;&#x4E00;&#x822C;&#x7684;&#x8A02;&#x95B1;&#x6216;&#x662F;&#x6587;&#x7AE0;&#x56DE;&#x8986;&#x662F;&#x53EF;&#x4EE5;&#x6536;&#x5230;Mail&#xFF0C;&#x4F46;&#x662F;&#x4E00;&#x65E6;&#x767C;&#x8868;&#x65B0;&#x6587;&#x7AE0;&#x6642;&#x537B;&#x6536;&#x4E0D;&#x5230;&#x4FE1;&#xFF0C;&#x9019;&#x6642;&#x5019;&#x9700;&#x8981;&#x5C07;&#x4F3A;&#x670D;&#x5668;&#x6240;&#x5728;&#x7684;IP&#x52A0;&#x5165;Mailgun&#x7684;IP&#x767D;&#x540D;&#x55AE;&#xFF0C;&#x9996;&#x5148;&#x9EDE;&#x9078;&#x53F3;&#x4E0A;&#x89D2;&#x7684;&#x500B;&#x4EBA;&#x8CC7;&#x8A0A;&#x3001;&#x9078;&#x64C7;<code>API Security</code>:</p><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/09/10.png" class="kg-image" alt="Ghost Blog Note 01" loading="lazy" width="280" height="552"></figure><p>&#x9EDE;&#x9078;&#x4E0A;&#x65B9;&#x7684;IP allow list:</p><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/09/image-2.png" class="kg-image" alt="Ghost Blog Note 01" loading="lazy" width="383" height="206"></figure><p>&#x9EDE;&#x9078;Add to allow list&#x5F8C;&#xFF0C;&#x5C07;Ghost Blog&#x6240;&#x5728;&#x7684;IP&#x586B;&#x5165;&#x5373;&#x53EF;:</p><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/09/image-3.png" class="kg-image" alt="Ghost Blog Note 01" loading="lazy" width="673" height="374" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/09/image-3.png 600w, https://ghost.augustushsu.com/content/images/2023/09/image-3.png 673w"></figure><p>&#x8A2D;&#x5B9A;&#x5B8C;&#x5F8C;&#x53EF;&#x4EE5;&#x81EA;&#x884C;&#x767C;&#x8868;&#x6587;&#x7AE0;&#x6E2C;&#x8A66;&#x770B;&#x770B;&#x6536;&#x4E0D;&#x6536;&#x7684;&#x5230;&#x4FE1;&#xFF0C;&#x76EE;&#x524D;Ghost Blog (5.59.2) &#x7684; Casper (5.7.0) &#x4E3B;&#x984C;&#x9810;&#x8A2D;&#x7684;&#x7559;&#x8A00;&#x65B9;&#x5F0F;&#x5728;&#x7559;&#x8A00;&#x7684;&#x6642;&#x5019;&#x540C;&#x6642;&#x6703;&#x5BC4;&#x4FE1;&#x7D66;&#x4F5C;&#x8005;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x5728;&#x6587;&#x7AE0;&#x4E0B;&#x7559;&#x8A00;&#x4F86;&#x6E2C;&#x8A66;&#x90F5;&#x4EF6;&#x662F;&#x5426;&#x80FD;&#x6B63;&#x5E38;&#x767C;&#x9001;&#x3002;</p><h2 id="google-analytics">Google Analytics</h2><p>&#x5982;&#x679C;&#x4F60;&#x662F;&#x7B2C;&#x4E00;&#x6B21;&#x4F7F;&#x7528;<a href="https://analytics.google.com/?ref=ghost.augustushsu.com">Google Analytics</a>&#x767B;&#x5165;&#x9032;&#x53BB;&#x5F8C;&#x6709;&#x4EE5;&#x4E0B;&#x756B;&#x9762;&#xFF0C;&#x9EDE;&#x9078;&#x958B;&#x59CB;&#x6E2C;&#x91CF;:</p><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/09/image-10.png" class="kg-image" alt="Ghost Blog Note 01" loading="lazy" width="890" height="210" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/09/image-10.png 600w, https://ghost.augustushsu.com/content/images/2023/09/image-10.png 890w" sizes="(min-width: 720px) 720px"></figure><p>&#x9996;&#x5148;&#x9700;&#x8981;&#x5148;&#x5275;&#x5EFA;&#x4E00;&#x500B;&#x5E33;&#x6236;&#xFF0C;&#x9019;&#x88E1;&#x7684;&#x5E33;&#x6236;&#x8CA0;&#x8CAC;&#x7BA1;&#x7406;&#x4F60;&#x8981;&#x5206;&#x6790;&#x7684;&#x8CC7;&#x6E90;&#xFF0C;&#x8CC7;&#x6E90;&#x53EF;&#x80FD;&#x662F;&#x7DB2;&#x7AD9;&#x6216;&#x662F;APP (ISO&#x6216;&#x662F;Android) :</p><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/09/image-13.png" class="kg-image" alt="Ghost Blog Note 01" loading="lazy" width="827" height="501" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/09/image-13.png 600w, https://ghost.augustushsu.com/content/images/2023/09/image-13.png 827w" sizes="(min-width: 720px) 720px"></figure><p>&#x63A5;&#x4E0B;&#x4F86;&#x5C31;&#x6309;&#x7167;&#x5B83;&#x4E0A;&#x9762;&#x6240;&#x5F15;&#x5C0E;&#x7684;&#x6B65;&#x9A5F;&#x628A;&#x5FC5;&#x8981;&#x7684;&#x8CC7;&#x8A0A;&#x4E00;&#x4E00;&#x586B;&#x5165;:</p><figure class="kg-card kg-gallery-card kg-width-wide"><div class="kg-gallery-container"><div class="kg-gallery-row"><div class="kg-gallery-image"><img src="https://ghost.augustushsu.com/content/images/2023/09/image-12.png" width="804" height="741" loading="lazy" alt="Ghost Blog Note 01" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/09/image-12.png 600w, https://ghost.augustushsu.com/content/images/2023/09/image-12.png 804w" sizes="(min-width: 720px) 720px"></div><div class="kg-gallery-image"><img src="https://ghost.augustushsu.com/content/images/2023/09/image-14.png" width="810" height="597" loading="lazy" alt="Ghost Blog Note 01" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/09/image-14.png 600w, https://ghost.augustushsu.com/content/images/2023/09/image-14.png 810w" sizes="(min-width: 720px) 720px"></div></div><div class="kg-gallery-row"><div class="kg-gallery-image"><img src="https://ghost.augustushsu.com/content/images/2023/09/image-15.png" width="814" height="781" loading="lazy" alt="Ghost Blog Note 01" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/09/image-15.png 600w, https://ghost.augustushsu.com/content/images/2023/09/image-15.png 814w" sizes="(min-width: 720px) 720px"></div><div class="kg-gallery-image"><img src="https://ghost.augustushsu.com/content/images/2023/09/image-16.png" width="600" height="540" loading="lazy" alt="Ghost Blog Note 01" srcset="https://ghost.augustushsu.com/content/images/2023/09/image-16.png 600w"></div></div></div></figure><p>&#x6211;&#x5011;&#x9700;&#x8981;&#x5206;&#x6790;&#x7684;&#x662F;&#x90E8;&#x843D;&#x683C;&#xFF0C;&#x6240;&#x4EE5;&#x9019;&#x908A;&#x9078;&#x64C7;&#x7DB2;&#x7AD9;:</p><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/09/image-17.png" class="kg-image" alt="Ghost Blog Note 01" loading="lazy" width="821" height="392" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/09/image-17.png 600w, https://ghost.augustushsu.com/content/images/2023/09/image-17.png 821w" sizes="(min-width: 720px) 720px"></figure><p>&#x628A;&#x7DB2;&#x7AD9;&#x7684;&#x8CC7;&#x8A0A;&#x586B;&#x5165;:</p><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/09/image-18.png" class="kg-image" alt="Ghost Blog Note 01" loading="lazy" width="744" height="451" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/09/image-18.png 600w, https://ghost.augustushsu.com/content/images/2023/09/image-18.png 744w" sizes="(min-width: 720px) 720px"></figure><p>&#x4E4B;&#x5F8C;&#x6703;&#x6311;&#x51FA;&#x4F86;Google Analytics&#x6240;&#x7522;&#x751F;&#x7684;JS&#x7A0B;&#x5F0F;&#x78BC;:</p><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/09/image-19.png" class="kg-image" alt="Ghost Blog Note 01" loading="lazy" width="727" height="476" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/09/image-19.png 600w, https://ghost.augustushsu.com/content/images/2023/09/image-19.png 727w" sizes="(min-width: 720px) 720px"></figure><p>&#x8907;&#x88FD;&#x524D;&#x9762;&#x7684;&#x7A0B;&#x5F0F;&#x78BC;&#xFF0C;&#x8CBC;&#x5230;Ghost Blog&#x7BA1;&#x7406;&#x4ECB;&#x9762;&#x88E1;Settings &gt; Code injection&#x7684;Header&#x88E1;&#x9762;:</p><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/09/image-27.png" class="kg-image" alt="Ghost Blog Note 01" loading="lazy" width="908" height="347" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/09/image-27.png 600w, https://ghost.augustushsu.com/content/images/2023/09/image-27.png 908w" sizes="(min-width: 720px) 720px"></figure><p>&#x63A5;&#x4E0B;&#x4F86;&#x9032;&#x5165;&#x90E8;&#x843D;&#x683C;&#x91CD;&#x65B0;&#x6574;&#x7406;&#x4E00;&#x4E0B;&#xFF0C;&#x53BB;&#x770B;Google Analytics&#x7684;&#x5831;&#x8868;&#x4E0A;&#x6709;&#x6C92;&#x6709;&#x7522;&#x751F;&#x700F;&#x89BD;&#x7D00;&#x9304;&#xFF0C;&#x5982;&#x679C;&#x6709;&#x4EE3;&#x8868;&#x5DF2;&#x7D93;&#x5B8C;&#x6210;&#x4E86;:</p><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/09/SmartSelect_20230906_104558_Chrome.jpg" class="kg-image" alt="Ghost Blog Note 01" loading="lazy" width="1003" height="631" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/09/SmartSelect_20230906_104558_Chrome.jpg 600w, https://ghost.augustushsu.com/content/images/size/w1000/2023/09/SmartSelect_20230906_104558_Chrome.jpg 1000w, https://ghost.augustushsu.com/content/images/2023/09/SmartSelect_20230906_104558_Chrome.jpg 1003w" sizes="(min-width: 720px) 720px"></figure><h2 id="google-news-sitemap">Google News Sitemap</h2><p>&#x53C3;&#x7167;Ghost&#x7684;<a href="https://ghost.org/tutorials/create-a-google-news-sitemap/?ref=ghost.augustushsu.com" rel="noreferrer">&#x6559;&#x5B78;&#x6587;&#x7AE0;</a>&#xFF0C;&#x65B0;&#x589E;<code>sitemap.hbs</code>:</p><pre><code class="language-xml">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;urlset
    xmlns=&quot;http://www.sitemaps.org/schemas/sitemap/0.9&quot;
    xmlns:news=&quot;http://www.google.com/schemas/sitemap-news/0.9&quot;
  &gt;
    {{#get &quot;posts&quot; filter=&quot;published_at:&gt;now-2d&quot; limit=&quot;1000&quot; include=&quot;tags&quot;}}
      {{#foreach posts}}
        &lt;url&gt;
          &lt;loc&gt;{{url absolute=&quot;true&quot;}}&lt;/loc&gt;
          &lt;news:news&gt;
            &lt;news:publication&gt;
              &lt;news:name&gt;{{@site.title}}&lt;/news:name&gt;
              &lt;news:language&gt;{{@site.locale}}&lt;/news:language&gt;
            &lt;/news:publication&gt;
            {{#has visibility=&quot;members&quot;}}
            &lt;news:access&gt;Registration&lt;/news:access&gt;
            {{/has}}
            {{#has visibility=&quot;paid&quot;}}
            &lt;news:access&gt;Subscription&lt;/news:access&gt;
            {{/has}}
            &lt;news:publication_date&gt;{{date published_at format=&quot;YYYY-MM-DDTHH:mm:ssZ&quot;}}&lt;/news:publication_date&gt;
            &lt;news:title&gt;{{title}}&lt;/news:title&gt;
            &lt;news:keywords&gt;{{tags limit=&quot;5&quot; autolink=&quot;false&quot;}}&lt;/news:keywords&gt;
          &lt;/news:news&gt;
        &lt;/url&gt;
      {{/foreach}}
    {{/get}}
  &lt;/urlset&gt;</code></pre><p>&#x66F4;&#x65B0;<code>route.yaml</code>&#xFF0C;&#x5728;<code>routes</code>&#x65B0;&#x589E;&#x4EE5;&#x4E0B;&#x9019;&#x6BB5;:</p><pre><code class="language-yaml">routes:
  /sitemap/:
    template: sitemap
    content_type: text/xml </code></pre><p>&#x9032;&#x5165;<a href="https://search.google.com/search-console/about?ref=ghost.augustushsu.com" rel="noreferrer">Google Search Console</a>&#x78BA;&#x8A8D;Google&#x662F;&#x5426;&#x6709;&#x5075;&#x6E2C;&#x5230;sitemap&#xFF0C;&#x56E0;&#x70BA;&#x76EE;&#x524D;&#x53EA;&#x6709;&#x9019;&#x500B;&#x7DB2;&#x7AD9;&#x9700;&#x8981;&#x4F7F;&#x7528;sitemap&#x7684;&#x529F;&#x80FD;&#xFF0C;&#x6240;&#x4EE5;&#x9078;&#x64C7;&#x53F3;&#x908A;&#x7684;&#x9078;&#x9805;&#x586B;&#x5165;&#x7DB2;&#x7AD9;&#x7684;&#x540D;&#x7A31;:</p><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://ghost.augustushsu.com/content/images/2023/09/image-21.png" class="kg-image" alt="Ghost Blog Note 01" loading="lazy" width="776" height="633" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/09/image-21.png 600w, https://ghost.augustushsu.com/content/images/2023/09/image-21.png 776w" sizes="(min-width: 720px) 720px"><figcaption><span>\</span></figcaption></figure><p>&#x56E0;&#x70BA;&#x4E4B;&#x524D;&#x5DF2;&#x7D93;&#x5B8C;&#x6210;&#x4E86;Google Analytics&#x7684;&#x9023;&#x7D50;&#xFF0C;&#x6240;&#x4EE5;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x9A57;&#x8B49;&#x70BA;&#x64C1;&#x6709;&#x8005;:</p><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/09/image-22.png" class="kg-image" alt="Ghost Blog Note 01" loading="lazy" width="649" height="297" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/09/image-22.png 600w, https://ghost.augustushsu.com/content/images/2023/09/image-22.png 649w"></figure><p>&#x9EDE;&#x9078;&#x5DE6;&#x65B9;&#x7684;Sitemap&#x9078;&#x9805;:</p><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/09/Screenshot-2023-09-06-232231.png" class="kg-image" alt="Ghost Blog Note 01" loading="lazy" width="276" height="311"></figure><p>&#x586B;&#x5165;&#x525B;&#x525B;&#x5275;&#x5EFA;&#x7684;sitemap&#x7DB2;&#x5740;&#xFF0C;&#x6700;&#x5F8C;&#x770B;&#x5230;&#x6210;&#x529F;&#x5C31;&#x4EE3;&#x8868;&#x5B8C;&#x6210;&#x4E86;:</p><figure class="kg-card kg-image-card"><img src="https://ghost.augustushsu.com/content/images/2023/09/Screenshot-2023-09-06-232609.png" class="kg-image" alt="Ghost Blog Note 01" loading="lazy" width="917" height="392" srcset="https://ghost.augustushsu.com/content/images/size/w600/2023/09/Screenshot-2023-09-06-232609.png 600w, https://ghost.augustushsu.com/content/images/2023/09/Screenshot-2023-09-06-232609.png 917w" sizes="(min-width: 720px) 720px"></figure><h2 id="%E7%B5%90%E8%AB%96">&#x7D50;&#x8AD6;</h2><p>&#x5230;&#x9019;&#x88E1;&#x95DC;&#x65BC;Ghost Blog&#x7684;&#x8A2D;&#x5B9A;&#x57FA;&#x672C;&#x4E0A;&#x5C31;&#x5B8C;&#x6210;&#x4E86;&#xFF0C;&#x4E4B;&#x5F8C;&#x5982;&#x679C;&#x6709;&#x65B0;&#x589E;&#x529F;&#x80FD;&#x6703;&#x4EE5;&#x8F03;&#x70BA;&#x77ED;&#x7BC7;&#x7684;&#x6587;&#x7AE0;&#x8A18;&#x9304;&#x3002;</p>]]></content:encoded></item></channel></rss>