<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Python on gpchn 栖息地</title><link>https://gpchn.252123.xyz/tags/python/</link><description>Recent content in Python on gpchn 栖息地</description><generator>Hugo</generator><language>en</language><lastBuildDate>Sun, 27 Jul 2025 22:05:12 +0000</lastBuildDate><atom:link href="https://gpchn.252123.xyz/tags/python/index.xml" rel="self" type="application/rss+xml"/><item><title>PyWebview 打包安卓全过程记录</title><link>https://gpchn.252123.xyz/posts/pywebview-%E6%89%93%E5%8C%85%E5%AE%89%E5%8D%93%E5%85%A8%E8%BF%87%E7%A8%8B%E8%AE%B0%E5%BD%95/</link><pubDate>Sun, 27 Jul 2025 22:05:12 +0000</pubDate><guid>https://gpchn.252123.xyz/posts/pywebview-%E6%89%93%E5%8C%85%E5%AE%89%E5%8D%93%E5%85%A8%E8%BF%87%E7%A8%8B%E8%AE%B0%E5%BD%95/</guid><description>&lt;p>用 PyWebview 写完应用，打包成 Android APK 是最后一步。官方文档给了方向，但细节需要自己摸索。以下是我验证过的完整流程。&lt;/p>
&lt;h2 id="1-准备-linux-环境">1. 准备 Linux 环境&lt;/h2>
&lt;p>Android 打包依赖 Buildozer，它只能跑在 Linux 上。Windows 用户可通过 WSL 搭建环境。&lt;/p></description></item><item><title>Python 中良好的码风是什么样的</title><link>https://gpchn.252123.xyz/posts/python-%E4%B8%AD%E8%89%AF%E5%A5%BD%E7%9A%84%E7%A0%81%E9%A3%8E%E6%98%AF%E4%BB%80%E4%B9%88%E6%A0%B7%E7%9A%84/</link><pubDate>Sat, 15 Mar 2025 15:38:13 +0000</pubDate><guid>https://gpchn.252123.xyz/posts/python-%E4%B8%AD%E8%89%AF%E5%A5%BD%E7%9A%84%E7%A0%81%E9%A3%8E%E6%98%AF%E4%BB%80%E4%B9%88%E6%A0%B7%E7%9A%84/</guid><description>&lt;p>我当前在 Python 脚本里保持的骨架大致如下：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-python" data-lang="python">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">#!/usr/bin/env python3&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># coding=utf-8&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">def&lt;/span> &lt;span style="color:#a6e22e">main&lt;/span>():
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">...&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">if&lt;/span> __name__ &lt;span style="color:#f92672">==&lt;/span> &lt;span style="color:#e6db74">&amp;#34;__main__&amp;#34;&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> main()
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>下面逐条解释这些选择，以及我在缩进、引号、空白上的习惯。&lt;/p>
&lt;h2 id="shebang">shebang&lt;/h2>
&lt;p>&lt;code>#!/usr/bin/env python3&lt;/code> 只在 Unix/类 Unix 系统上生效，Windows 会直接忽略这一行。它的作用是让内核用 &lt;code>env&lt;/code> 找到 &lt;code>python3&lt;/code> 来执行脚本，而不是硬编码 &lt;code>/usr/bin/python3&lt;/code> 这样可能不存在的路径。对要用 &lt;code>./script.py&lt;/code> 直接跑脚本的人来说，这行算基本礼貌，省去先敲 &lt;code>python3&lt;/code> 的步骤。&lt;/p></description></item></channel></rss>