<?xml version="1.0" encoding="utf-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><title>卡卡博客</title><link>https://www.tuiedu.org/</link><description>SEO优化、网络营销、网络安全技术研究！</description><item><title>python打包exe文件教程</title><link>https://www.tuiedu.org/132.html</link><description>&lt;div class=&quot;Post-RichTextContainer&quot; style=&quot;position: relative; margin: 0px auto; overflow: visible; width: 690px; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Source Han Sans SC&amp;quot;, &amp;quot;Noto Sans CJK SC&amp;quot;, &amp;quot;WenQuanYi Micro Hei&amp;quot;, sans-serif; font-size: medium; text-wrap: wrap; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div class=&quot;css-1od93p9&quot; style=&quot;margin-top: 16px; position: relative;&quot;&gt;&lt;div class=&quot;css-376mun&quot; style=&quot;position: relative; display: inline;&quot;&gt;&lt;div class=&quot;RichText ztext Post-RichText css-ob6uua&quot; options=&quot;[object Object]&quot; deep=&quot;8&quot; style=&quot;line-height: 1.6; word-break: break-word;&quot;&gt;&lt;p data-first-child=&quot;&quot; data-pid=&quot;w6NpDoBG&quot; style=&quot;margin-top: 0px; margin-bottom: 1.4em;&quot;&gt;在 Python 项目开发中，打包成二进制文件&lt;svg width=&quot;10px&quot; height=&quot;10px&quot; viewbox=&quot;0 0 16 16&quot; class=&quot;ZDI ZDI--FourPointedStar16 css-1dvsrp&quot; fill=&quot;currentColor&quot;&gt;&lt;path d=&quot;m5.068 9.267-3.08-.77a.512.512 0 0 1 0-.994l3.08-.77a2.289 2.289 0 0 0 1.665-1.665l.77-3.08a.512.512 0 0 1 .994 0l.77 3.08c.205.82.845 1.46 1.665 1.665l3.08.77a.512.512 0 0 1 0 .994l-3.08.77a2.29 2.29 0 0 0-1.665 1.665l-.77 3.08a.512.512 0 0 1-.994 0l-.77-3.08a2.289 2.289 0 0 0-1.665-1.665Z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;a class=&quot;RichContent-EntityWord css-b7erz1&quot; data-za-not-track-link=&quot;true&quot; data-paste-text=&quot;true&quot; href=&quot;https://zhida.zhihu.com/search?content_id=251875255&amp;content_type=Article&amp;match_order=1&amp;q=%E4%BA%8C%E8%BF%9B%E5%88%B6%E6%96%87%E4%BB%B6&amp;zhida_source=entity&quot; target=&quot;_blank&quot; style=&quot;text-decoration-line: none; color: rgb(9, 64, 142); cursor: pointer;&quot;&gt;&lt;svg width=&quot;10px&quot; height=&quot;10px&quot; viewbox=&quot;0 0 16 16&quot; class=&quot;ZDI ZDI--FourPointedStar16 css-1dvsrp&quot; fill=&quot;currentColor&quot;&gt;&lt;path d=&quot;m5.068 9.267-3.08-.77a.512.512 0 0 1 0-.994l3.08-.77a2.289 2.289 0 0 0 1.665-1.665l.77-3.08a.512.512 0 0 1 .994 0l.77 3.08c.205.82.845 1.46 1.665 1.665l3.08.77a.512.512 0 0 1 0 .994l-3.08.77a2.29 2.29 0 0 0-1.665 1.665l-.77 3.08a.512.512 0 0 1-.994 0l-.77-3.08a2.289 2.289 0 0 0-1.665-1.665Z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;让项目能够独立运行，无需额外的 Python 解释器或依赖环境，极大方便了部署和发布。本文将详细介绍如何使用 PyInstaller 工具打包多文件 Python 项目，如何添加应用图标，以及如何打包资源文件（如配置文件、图像等）到最终的可执行文件&lt;svg width=&quot;10px&quot; height=&quot;10px&quot; viewbox=&quot;0 0 16 16&quot; class=&quot;ZDI ZDI--FourPointedStar16 css-1dvsrp&quot; fill=&quot;currentColor&quot;&gt;&lt;path d=&quot;m5.068 9.267-3.08-.77a.512.512 0 0 1 0-.994l3.08-.77a2.289 2.289 0 0 0 1.665-1.665l.77-3.08a.512.512 0 0 1 .994 0l.77 3.08c.205.82.845 1.46 1.665 1.665l3.08.77a.512.512 0 0 1 0 .994l-3.08.77a2.29 2.29 0 0 0-1.665 1.665l-.77 3.08a.512.512 0 0 1-.994 0l-.77-3.08a2.289 2.289 0 0 0-1.665-1.665Z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;a class=&quot;RichContent-EntityWord css-b7erz1&quot; data-za-not-track-link=&quot;true&quot; data-paste-text=&quot;true&quot; href=&quot;https://zhida.zhihu.com/search?content_id=251875255&amp;content_type=Article&amp;match_order=1&amp;q=%E5%8F%AF%E6%89%A7%E8%A1%8C%E6%96%87%E4%BB%B6&amp;zhida_source=entity&quot; target=&quot;_blank&quot; style=&quot;text-decoration-line: none; color: rgb(9, 64, 142); cursor: pointer;&quot;&gt;&lt;svg width=&quot;10px&quot; height=&quot;10px&quot; viewbox=&quot;0 0 16 16&quot; class=&quot;ZDI ZDI--FourPointedStar16 css-1dvsrp&quot; fill=&quot;currentColor&quot;&gt;&lt;path d=&quot;m5.068 9.267-3.08-.77a.512.512 0 0 1 0-.994l3.08-.77a2.289 2.289 0 0 0 1.665-1.665l.77-3.08a.512.512 0 0 1 .994 0l.77 3.08c.205.82.845 1.46 1.665 1.665l3.08.77a.512.512 0 0 1 0 .994l-3.08.77a2.29 2.29 0 0 0-1.665 1.665l-.77 3.08a.512.512 0 0 1-.994 0l-.77-3.08a2.289 2.289 0 0 0-1.665-1.665Z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;中。&lt;/p&gt;&lt;h3 style=&quot;font-style: inherit; font-variant: inherit; font-stretch: inherit; font-size: 1.1em; line-height: 1.5; font-family: inherit; font-optical-sizing: inherit; font-kerning: inherit; font-feature-settings: inherit; font-variation-settings: inherit; margin: calc(1.90909em) 0px calc(1.27273em); clear: left;&quot;&gt;1. PyInstaller 简介&lt;/h3&gt;&lt;p data-pid=&quot;xqbGExa-&quot; style=&quot;margin-top: 1.4em; margin-bottom: 1.4em;&quot;&gt;PyInstaller 是一个可以将 Python&amp;nbsp;源代码&lt;svg width=&quot;10px&quot; height=&quot;10px&quot; viewbox=&quot;0 0 16 16&quot; class=&quot;ZDI ZDI--FourPointedStar16 css-1dvsrp&quot; fill=&quot;currentColor&quot;&gt;&lt;path d=&quot;m5.068 9.267-3.08-.77a.512.512 0 0 1 0-.994l3.08-.77a2.289 2.289 0 0 0 1.665-1.665l.77-3.08a.512.512 0 0 1 .994 0l.77 3.08c.205.82.845 1.46 1.665 1.665l3.08.77a.512.512 0 0 1 0 .994l-3.08.77a2.29 2.29 0 0 0-1.665 1.665l-.77 3.08a.512.512 0 0 1-.994 0l-.77-3.08a2.289 2.289 0 0 0-1.665-1.665Z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;a class=&quot;RichContent-EntityWord css-b7erz1&quot; data-za-not-track-link=&quot;true&quot; data-paste-text=&quot;true&quot; href=&quot;https://zhida.zhihu.com/search?content_id=251875255&amp;content_type=Article&amp;match_order=1&amp;q=%E6%BA%90%E4%BB%A3%E7%A0%81&amp;zhida_source=entity&quot; target=&quot;_blank&quot; style=&quot;text-decoration-line: none; color: rgb(9, 64, 142); cursor: pointer;&quot;&gt;&lt;svg width=&quot;10px&quot; height=&quot;10px&quot; viewbox=&quot;0 0 16 16&quot; class=&quot;ZDI ZDI--FourPointedStar16 css-1dvsrp&quot; fill=&quot;currentColor&quot;&gt;&lt;path d=&quot;m5.068 9.267-3.08-.77a.512.512 0 0 1 0-.994l3.08-.77a2.289 2.289 0 0 0 1.665-1.665l.77-3.08a.512.512 0 0 1 .994 0l.77 3.08c.205.82.845 1.46 1.665 1.665l3.08.77a.512.512 0 0 1 0 .994l-3.08.77a2.29 2.29 0 0 0-1.665 1.665l-.77 3.08a.512.512 0 0 1-.994 0l-.77-3.08a2.289 2.289 0 0 0-1.665-1.665Z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;打包成跨平台独立可执行文件的工具。无论是 Windows、Linux 还是 macOS，PyInstaller 都能够创建不依赖于 Python 解释器的二进制文件。&lt;/p&gt;&lt;p data-pid=&quot;VnDG3Xod&quot; style=&quot;margin-top: 1.4em; margin-bottom: 1.4em;&quot;&gt;&lt;span style=&quot;font-weight: 600;&quot;&gt;常见应用场景：&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;list-style-type: none;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;• 分发给不具备 Python 环境的用户。&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;• 打包包含多个模块、数据文件和资源文件的复杂项目。&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;• 设置自定义的图标和名称。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 style=&quot;font-style: inherit; font-variant: inherit; font-stretch: inherit; font-size: 1.1em; line-height: 1.5; font-family: inherit; font-optical-sizing: inherit; font-kerning: inherit; font-feature-settings: inherit; font-variation-settings: inherit; margin: calc(1.90909em) 0px calc(1.27273em); clear: left;&quot;&gt;2. 安装 PyInstaller&lt;/h3&gt;&lt;p data-pid=&quot;Re-mymef&quot; style=&quot;margin-top: 1.4em; margin-bottom: 1.4em;&quot;&gt;首先，确保你已经安装了 PyInstaller。通过 pip 可以轻松安装：&lt;/p&gt;&lt;div class=&quot;highlight&quot; style=&quot;margin: 1em 0px;&quot;&gt;&lt;pre style=&quot;margin-top: 0px; margin-bottom: 0px; overflow-wrap: initial; background-color: rgb(248, 248, 250); border-radius: 4px; font-size: 0.9em; overflow: auto; padding: calc(0.888889em); word-break: initial;&quot;&gt;pip&amp;nbsp;install&amp;nbsp;pyinstaller&lt;/pre&gt;&lt;/div&gt;&lt;h3 style=&quot;font-style: inherit; font-variant: inherit; font-stretch: inherit; font-size: 1.1em; line-height: 1.5; font-family: inherit; font-optical-sizing: inherit; font-kerning: inherit; font-feature-settings: inherit; font-variation-settings: inherit; margin: calc(1.90909em) 0px calc(1.27273em); clear: left;&quot;&gt;3. 准备你的项目&lt;/h3&gt;&lt;p data-pid=&quot;j0hb3Bbm&quot; style=&quot;margin-top: 1.4em; margin-bottom: 1.4em;&quot;&gt;假设你的 Python 项目目录结构如下：&lt;/p&gt;&lt;div class=&quot;highlight&quot; style=&quot;margin: 1em 0px;&quot;&gt;&lt;pre style=&quot;margin-top: 0px; margin-bottom: 0px; overflow-wrap: initial; background-color: rgb(248, 248, 250); border-radius: 4px; font-size: 0.9em; overflow: auto; padding: calc(0.888889em); word-break: initial;&quot;&gt;project/
├──&amp;nbsp;main.py&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;主程序文件├──&amp;nbsp;module1.py&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;额外模块
├──&amp;nbsp;data/&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;存放附件
│&amp;nbsp;&amp;nbsp;&amp;nbsp;└──&amp;nbsp;config.json&amp;nbsp;&amp;nbsp;#&amp;nbsp;配置文件
└──&amp;nbsp;assets/&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;资源文件夹
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;└──&amp;nbsp;app.ico&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;应用程序图标&lt;/pre&gt;&lt;/div&gt;&lt;p data-pid=&quot;XRvkVIit&quot; style=&quot;margin-top: 1.4em; margin-bottom: 1.4em;&quot;&gt;你需要确保&amp;nbsp;&lt;code style=&quot;background-color: rgb(248, 248, 250); border-radius: 3px; font-family: Menlo, Monaco, Consolas, &amp;quot;Andale Mono&amp;quot;, &amp;quot;lucida console&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.9em; margin: 0px 2px; padding: 3px 4px;&quot;&gt;main.py&lt;/code&gt;&amp;nbsp;是你的主入口文件，而其他模块和资源也需要在打包时一起包含。&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;text-wrap: nowrap;&quot;&gt;下面是pyinstaller的常用参数：&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;text-wrap: nowrap;&quot;&gt;--name : 指定可执行文件名称&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;text-wrap: nowrap;&quot;&gt;--specpath: 指定spec文件的生成目录，默认为当前目录&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;text-wrap: nowrap;&quot;&gt;-F, --onefile: 将整个应用程序打包到单个可执行文件中&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;text-wrap: nowrap;&quot;&gt;-D, --onedir: 生成一个目录，包含多个文件&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;text-wrap: nowrap;&quot;&gt;--add-data 、 --add-binary： 在构建中插入额外的数据或二进制文件，可用于绑定配置文件、示例或其他非代码数据。&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;text-wrap: nowrap;&quot;&gt;--exclude-module: 排除某些模块&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;text-wrap: nowrap;&quot;&gt;-d, --debug: 提供debug输出。-w, --windowed, --noconsole: 关闭控制台窗口(仅对Windows有效)。&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;text-wrap: nowrap;&quot;&gt;-c, --nowindowed, --console: 使用命令行窗口(仅对Windows有效)&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;text-wrap: nowrap;&quot;&gt;-i: 设置应用图标&lt;/span&gt;&lt;/p&gt;&lt;h3 style=&quot;font-style: inherit; font-variant: inherit; font-stretch: inherit; font-size: 1.1em; line-height: 1.5; font-family: inherit; font-optical-sizing: inherit; font-kerning: inherit; font-feature-settings: inherit; font-variation-settings: inherit; margin: calc(1.90909em) 0px calc(1.27273em); clear: left;&quot;&gt;4. 基本打包命令&lt;/h3&gt;&lt;p data-pid=&quot;9ODcr2-6&quot; style=&quot;margin-top: 1.4em; margin-bottom: 1.4em;&quot;&gt;使用 PyInstaller 打包最基本的命令如下：&lt;/p&gt;&lt;div class=&quot;highlight&quot; style=&quot;margin: 1em 0px;&quot;&gt;&lt;pre style=&quot;margin-top: 0px; margin-bottom: 0px; overflow-wrap: initial; background-color: rgb(248, 248, 250); border-radius: 4px; font-size: 0.9em; overflow: auto; padding: calc(0.888889em); word-break: initial;&quot;&gt;pyinstaller&amp;nbsp;--onefile&amp;nbsp;main.py&lt;/pre&gt;&lt;/div&gt;&lt;ul style=&quot;list-style-type: none;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;•&amp;nbsp;&lt;code style=&quot;background-color: rgb(248, 248, 250); border-radius: 3px; font-family: Menlo, Monaco, Consolas, &amp;quot;Andale Mono&amp;quot;, &amp;quot;lucida console&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.9em; margin: 0px 2px; padding: 3px 4px;&quot;&gt;--onefile&lt;/code&gt;&amp;nbsp;参数告诉 PyInstaller 将所有内容打包到一个独立的二进制文件中。&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;• 最终生成的可执行文件会放在&amp;nbsp;&lt;code style=&quot;background-color: rgb(248, 248, 250); border-radius: 3px; font-family: Menlo, Monaco, Consolas, &amp;quot;Andale Mono&amp;quot;, &amp;quot;lucida console&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.9em; margin: 0px 2px; padding: 3px 4px;&quot;&gt;dist/&lt;/code&gt;&amp;nbsp;目录下。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 style=&quot;font-style: inherit; font-variant: inherit; font-stretch: inherit; font-size: 1.1em; line-height: 1.5; font-family: inherit; font-optical-sizing: inherit; font-kerning: inherit; font-feature-settings: inherit; font-variation-settings: inherit; margin: calc(1.90909em) 0px calc(1.27273em); clear: left;&quot;&gt;5. 添加图标&lt;/h3&gt;&lt;p data-pid=&quot;JwVmm32c&quot; style=&quot;margin-top: 1.4em; margin-bottom: 1.4em;&quot;&gt;如果你的应用需要自定义图标，可以通过&amp;nbsp;&lt;code style=&quot;background-color: rgb(248, 248, 250); border-radius: 3px; font-family: Menlo, Monaco, Consolas, &amp;quot;Andale Mono&amp;quot;, &amp;quot;lucida console&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.9em; margin: 0px 2px; padding: 3px 4px;&quot;&gt;--icon&lt;/code&gt;&amp;nbsp;参数指定图标文件&lt;svg width=&quot;10px&quot; height=&quot;10px&quot; viewbox=&quot;0 0 16 16&quot; class=&quot;ZDI ZDI--FourPointedStar16 css-1dvsrp&quot; fill=&quot;currentColor&quot;&gt;&lt;path d=&quot;m5.068 9.267-3.08-.77a.512.512 0 0 1 0-.994l3.08-.77a2.289 2.289 0 0 0 1.665-1.665l.77-3.08a.512.512 0 0 1 .994 0l.77 3.08c.205.82.845 1.46 1.665 1.665l3.08.77a.512.512 0 0 1 0 .994l-3.08.77a2.29 2.29 0 0 0-1.665 1.665l-.77 3.08a.512.512 0 0 1-.994 0l-.77-3.08a2.289 2.289 0 0 0-1.665-1.665Z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;a class=&quot;RichContent-EntityWord css-b7erz1&quot; data-za-not-track-link=&quot;true&quot; data-paste-text=&quot;true&quot; href=&quot;https://zhida.zhihu.com/search?content_id=251875255&amp;content_type=Article&amp;match_order=1&amp;q=%E5%9B%BE%E6%A0%87%E6%96%87%E4%BB%B6&amp;zhida_source=entity&quot; target=&quot;_blank&quot; style=&quot;text-decoration-line: none; color: rgb(9, 64, 142); cursor: pointer;&quot;&gt;&lt;svg width=&quot;10px&quot; height=&quot;10px&quot; viewbox=&quot;0 0 16 16&quot; class=&quot;ZDI ZDI--FourPointedStar16 css-1dvsrp&quot; fill=&quot;currentColor&quot;&gt;&lt;path d=&quot;m5.068 9.267-3.08-.77a.512.512 0 0 1 0-.994l3.08-.77a2.289 2.289 0 0 0 1.665-1.665l.77-3.08a.512.512 0 0 1 .994 0l.77 3.08c.205.82.845 1.46 1.665 1.665l3.08.77a.512.512 0 0 1 0 .994l-3.08.77a2.29 2.29 0 0 0-1.665 1.665l-.77 3.08a.512.512 0 0 1-.994 0l-.77-3.08a2.289 2.289 0 0 0-1.665-1.665Z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;：&lt;/p&gt;&lt;div class=&quot;highlight&quot; style=&quot;margin: 1em 0px;&quot;&gt;&lt;pre style=&quot;margin-top: 0px; margin-bottom: 0px; overflow-wrap: initial; background-color: rgb(248, 248, 250); border-radius: 4px; font-size: 0.9em; overflow: auto; padding: calc(0.888889em); word-break: initial;&quot;&gt;pyinstaller&amp;nbsp;--onefile&amp;nbsp;--icon=assets/app.ico&amp;nbsp;main.py&lt;/pre&gt;&lt;/div&gt;&lt;p data-pid=&quot;ejUupNBz&quot; style=&quot;margin-top: 1.4em; margin-bottom: 1.4em;&quot;&gt;这将为生成的可执行文件添加自定义图标。&lt;/p&gt;&lt;h3 style=&quot;font-style: inherit; font-variant: inherit; font-stretch: inherit; font-size: 1.1em; line-height: 1.5; font-family: inherit; font-optical-sizing: inherit; font-kerning: inherit; font-feature-settings: inherit; font-variation-settings: inherit; margin: calc(1.90909em) 0px calc(1.27273em); clear: left;&quot;&gt;6. 打包多文件和资源&lt;/h3&gt;&lt;p data-pid=&quot;90QcpzZk&quot; style=&quot;margin-top: 1.4em; margin-bottom: 1.4em;&quot;&gt;项目中往往包含一些非 Python 文件，如配置文件&lt;svg width=&quot;10px&quot; height=&quot;10px&quot; viewbox=&quot;0 0 16 16&quot; class=&quot;ZDI ZDI--FourPointedStar16 css-1dvsrp&quot; fill=&quot;currentColor&quot;&gt;&lt;path d=&quot;m5.068 9.267-3.08-.77a.512.512 0 0 1 0-.994l3.08-.77a2.289 2.289 0 0 0 1.665-1.665l.77-3.08a.512.512 0 0 1 .994 0l.77 3.08c.205.82.845 1.46 1.665 1.665l3.08.77a.512.512 0 0 1 0 .994l-3.08.77a2.29 2.29 0 0 0-1.665 1.665l-.77 3.08a.512.512 0 0 1-.994 0l-.77-3.08a2.289 2.289 0 0 0-1.665-1.665Z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;a class=&quot;RichContent-EntityWord css-b7erz1&quot; data-za-not-track-link=&quot;true&quot; data-paste-text=&quot;true&quot; href=&quot;https://zhida.zhihu.com/search?content_id=251875255&amp;content_type=Article&amp;match_order=3&amp;q=%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6&amp;zhida_source=entity&quot; target=&quot;_blank&quot; style=&quot;text-decoration-line: none; color: rgb(9, 64, 142); cursor: pointer;&quot;&gt;&lt;svg width=&quot;10px&quot; height=&quot;10px&quot; viewbox=&quot;0 0 16 16&quot; class=&quot;ZDI ZDI--FourPointedStar16 css-1dvsrp&quot; fill=&quot;currentColor&quot;&gt;&lt;path d=&quot;m5.068 9.267-3.08-.77a.512.512 0 0 1 0-.994l3.08-.77a2.289 2.289 0 0 0 1.665-1.665l.77-3.08a.512.512 0 0 1 .994 0l.77 3.08c.205.82.845 1.46 1.665 1.665l3.08.77a.512.512 0 0 1 0 .994l-3.08.77a2.29 2.29 0 0 0-1.665 1.665l-.77 3.08a.512.512 0 0 1-.994 0l-.77-3.08a2.289 2.289 0 0 0-1.665-1.665Z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;、图片等。这些文件需要在打包时一起捆绑，以便在运行时访问。&lt;/p&gt;&lt;p data-pid=&quot;_Q7sFTf2&quot; style=&quot;margin-top: 1.4em; margin-bottom: 1.4em;&quot;&gt;使用&amp;nbsp;&lt;code style=&quot;background-color: rgb(248, 248, 250); border-radius: 3px; font-family: Menlo, Monaco, Consolas, &amp;quot;Andale Mono&amp;quot;, &amp;quot;lucida console&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.9em; margin: 0px 2px; padding: 3px 4px;&quot;&gt;--add-data&lt;/code&gt;&amp;nbsp;参数可以将外部文件打包进去。格式如下：&lt;/p&gt;&lt;div class=&quot;highlight&quot; style=&quot;margin: 1em 0px;&quot;&gt;&lt;pre style=&quot;margin-top: 0px; margin-bottom: 0px; overflow-wrap: initial; background-color: rgb(248, 248, 250); border-radius: 4px; font-size: 0.9em; overflow: auto; padding: calc(0.888889em); word-break: initial;&quot;&gt;pyinstaller&amp;nbsp;--onefile&amp;nbsp;--add-data&amp;nbsp;&amp;quot;source_path;destination_path&amp;quot;&amp;nbsp;main.py&lt;/pre&gt;&lt;/div&gt;&lt;p data-pid=&quot;0bMq0ujY&quot; style=&quot;margin-top: 1.4em; margin-bottom: 1.4em;&quot;&gt;例如，如果你需要打包&amp;nbsp;&lt;code style=&quot;background-color: rgb(248, 248, 250); border-radius: 3px; font-family: Menlo, Monaco, Consolas, &amp;quot;Andale Mono&amp;quot;, &amp;quot;lucida console&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.9em; margin: 0px 2px; padding: 3px 4px;&quot;&gt;data/config.json&lt;/code&gt;&amp;nbsp;和&amp;nbsp;&lt;code style=&quot;background-color: rgb(248, 248, 250); border-radius: 3px; font-family: Menlo, Monaco, Consolas, &amp;quot;Andale Mono&amp;quot;, &amp;quot;lucida console&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.9em; margin: 0px 2px; padding: 3px 4px;&quot;&gt;assets/app.ico&lt;/code&gt;：&lt;/p&gt;&lt;div class=&quot;highlight&quot; style=&quot;margin: 1em 0px;&quot;&gt;&lt;pre style=&quot;margin-top: 0px; margin-bottom: 0px; overflow-wrap: initial; background-color: rgb(248, 248, 250); border-radius: 4px; font-size: 0.9em; overflow: auto; padding: calc(0.888889em); word-break: initial;&quot;&gt;pyinstaller&amp;nbsp;--onefile&amp;nbsp;--add-data&amp;nbsp;&amp;quot;data/config.json;data&amp;quot;&amp;nbsp;--add-data&amp;nbsp;&amp;quot;assets/app.ico;assets&amp;quot;&amp;nbsp;--icon=assets/app.ico&amp;nbsp;main.py&lt;/pre&gt;&lt;/div&gt;&lt;p data-pid=&quot;TRauo5e7&quot; style=&quot;margin-top: 1.4em; margin-bottom: 1.4em;&quot;&gt;&lt;span style=&quot;font-weight: 600;&quot;&gt;注意：&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;list-style-type: none;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;• 在 Windows 中，源路径和目标路径使用分号&amp;nbsp;&lt;code style=&quot;background-color: rgb(248, 248, 250); border-radius: 3px; font-family: Menlo, Monaco, Consolas, &amp;quot;Andale Mono&amp;quot;, &amp;quot;lucida console&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.9em; margin: 0px 2px; padding: 3px 4px;&quot;&gt;;&lt;/code&gt;&amp;nbsp;分隔。&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;• 在 Linux 和 macOS 中，使用冒号&amp;nbsp;&lt;code style=&quot;background-color: rgb(248, 248, 250); border-radius: 3px; font-family: Menlo, Monaco, Consolas, &amp;quot;Andale Mono&amp;quot;, &amp;quot;lucida console&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.9em; margin: 0px 2px; padding: 3px 4px;&quot;&gt;:&lt;/code&gt;&amp;nbsp;分隔。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p data-pid=&quot;M37Snq4z&quot; style=&quot;margin-top: 1.4em; margin-bottom: 1.4em;&quot;&gt;macOS 下正确的打包命令：&lt;/p&gt;&lt;div class=&quot;highlight&quot; style=&quot;margin: 1em 0px;&quot;&gt;&lt;pre style=&quot;margin-top: 0px; margin-bottom: 0px; overflow-wrap: initial; background-color: rgb(248, 248, 250); border-radius: 4px; font-size: 0.9em; overflow: auto; padding: calc(0.888889em); word-break: initial;&quot;&gt;pyinstaller&amp;nbsp;--onefile&amp;nbsp;--add-data&amp;nbsp;&amp;quot;data/config.json:data&amp;quot;&amp;nbsp;--icon=assets/app.ico&amp;nbsp;main.py&lt;/pre&gt;&lt;/div&gt;&lt;h3 style=&quot;font-style: inherit; font-variant: inherit; font-stretch: inherit; font-size: 1.1em; line-height: 1.5; font-family: inherit; font-optical-sizing: inherit; font-kerning: inherit; font-feature-settings: inherit; font-variation-settings: inherit; margin: calc(1.90909em) 0px calc(1.27273em); clear: left;&quot;&gt;7. 处理打包后的资源路径&lt;/h3&gt;&lt;p data-pid=&quot;2TZGM1QF&quot; style=&quot;margin-top: 1.4em; margin-bottom: 1.4em;&quot;&gt;PyInstaller 打包后，资源文件的路径会发生变化，因为 PyInstaller 将它们放在一个临时文件夹中。这时，你需要在代码中使用特定的方式来处理文件路径。&lt;/p&gt;&lt;p data-pid=&quot;15z2eryQ&quot; style=&quot;margin-top: 1.4em; margin-bottom: 1.4em;&quot;&gt;定义一个工具函数&lt;svg width=&quot;10px&quot; height=&quot;10px&quot; viewbox=&quot;0 0 16 16&quot; class=&quot;ZDI ZDI--FourPointedStar16 css-1dvsrp&quot; fill=&quot;currentColor&quot;&gt;&lt;path d=&quot;m5.068 9.267-3.08-.77a.512.512 0 0 1 0-.994l3.08-.77a2.289 2.289 0 0 0 1.665-1.665l.77-3.08a.512.512 0 0 1 .994 0l.77 3.08c.205.82.845 1.46 1.665 1.665l3.08.77a.512.512 0 0 1 0 .994l-3.08.77a2.29 2.29 0 0 0-1.665 1.665l-.77 3.08a.512.512 0 0 1-.994 0l-.77-3.08a2.289 2.289 0 0 0-1.665-1.665Z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;a class=&quot;RichContent-EntityWord css-b7erz1&quot; data-za-not-track-link=&quot;true&quot; data-paste-text=&quot;true&quot; href=&quot;https://zhida.zhihu.com/search?content_id=251875255&amp;content_type=Article&amp;match_order=1&amp;q=%E5%B7%A5%E5%85%B7%E5%87%BD%E6%95%B0&amp;zhida_source=entity&quot; target=&quot;_blank&quot; style=&quot;text-decoration-line: none; color: rgb(9, 64, 142); cursor: pointer;&quot;&gt;&lt;svg width=&quot;10px&quot; height=&quot;10px&quot; viewbox=&quot;0 0 16 16&quot; class=&quot;ZDI ZDI--FourPointedStar16 css-1dvsrp&quot; fill=&quot;currentColor&quot;&gt;&lt;path d=&quot;m5.068 9.267-3.08-.77a.512.512 0 0 1 0-.994l3.08-.77a2.289 2.289 0 0 0 1.665-1.665l.77-3.08a.512.512 0 0 1 .994 0l.77 3.08c.205.82.845 1.46 1.665 1.665l3.08.77a.512.512 0 0 1 0 .994l-3.08.77a2.29 2.29 0 0 0-1.665 1.665l-.77 3.08a.512.512 0 0 1-.994 0l-.77-3.08a2.289 2.289 0 0 0-1.665-1.665Z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;来获取正确的文件路径：&lt;/p&gt;&lt;div class=&quot;highlight&quot; style=&quot;margin: 1em 0px;&quot;&gt;&lt;pre style=&quot;margin-top: 0px; margin-bottom: 0px; overflow-wrap: initial; background-color: rgb(248, 248, 250); border-radius: 4px; font-size: 0.9em; overflow: auto; padding: calc(0.888889em); word-break: initial;&quot;&gt;import&amp;nbsp;os
import&amp;nbsp;sys

def&amp;nbsp;resource_path(relative_path):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;&amp;quot;&amp;quot;获取打包后资源文件的绝对路径&amp;quot;&amp;quot;&amp;quot;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&amp;nbsp;hasattr(sys,&amp;nbsp;&amp;#39;_MEIPASS&amp;#39;):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;如果是打包后的环境
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;base_path&amp;nbsp;=&amp;nbsp;sys._MEIPASS
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;开发环境，直接使用当前路径
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;base_path&amp;nbsp;=&amp;nbsp;os.path.abspath(&amp;quot;.&amp;quot;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;os.path.join(base_path,&amp;nbsp;relative_path)&lt;/pre&gt;&lt;/div&gt;&lt;p data-pid=&quot;LRqomS6w&quot; style=&quot;margin-top: 1.4em; margin-bottom: 1.4em;&quot;&gt;然后，当你访问资源文件时，使用&amp;nbsp;&lt;code style=&quot;background-color: rgb(248, 248, 250); border-radius: 3px; font-family: Menlo, Monaco, Consolas, &amp;quot;Andale Mono&amp;quot;, &amp;quot;lucida console&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.9em; margin: 0px 2px; padding: 3px 4px;&quot;&gt;resource_path&lt;/code&gt;&amp;nbsp;来处理路径。例如，读取&amp;nbsp;&lt;code style=&quot;background-color: rgb(248, 248, 250); border-radius: 3px; font-family: Menlo, Monaco, Consolas, &amp;quot;Andale Mono&amp;quot;, &amp;quot;lucida console&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.9em; margin: 0px 2px; padding: 3px 4px;&quot;&gt;data/config.json&lt;/code&gt;：&lt;/p&gt;&lt;div class=&quot;highlight&quot; style=&quot;margin: 1em 0px;&quot;&gt;&lt;pre style=&quot;margin-top: 0px; margin-bottom: 0px; overflow-wrap: initial; background-color: rgb(248, 248, 250); border-radius: 4px; font-size: 0.9em; overflow: auto; padding: calc(0.888889em); word-break: initial;&quot;&gt;config_path&amp;nbsp;=&amp;nbsp;resource_path(&amp;#39;data/config.json&amp;#39;)
with&amp;nbsp;open(config_path,&amp;nbsp;&amp;#39;r&amp;#39;,&amp;nbsp;encoding=&amp;#39;utf-8&amp;#39;)&amp;nbsp;as&amp;nbsp;config_file:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;config&amp;nbsp;=&amp;nbsp;json.load(config_file)&lt;/pre&gt;&lt;/div&gt;&lt;p data-pid=&quot;zdEtTyJI&quot; style=&quot;margin-top: 1.4em; margin-bottom: 1.4em;&quot;&gt;如下：&lt;/p&gt;&lt;div class=&quot;highlight&quot; style=&quot;margin: 1em 0px;&quot;&gt;&lt;pre style=&quot;margin-top: 0px; margin-bottom: 0px; overflow-wrap: initial; background-color: rgb(248, 248, 250); border-radius: 4px; font-size: 0.9em; overflow: auto; padding: calc(0.888889em); word-break: initial;&quot;&gt;import&amp;nbsp;os
import&amp;nbsp;sys

def&amp;nbsp;resource_path(relative_path):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;&amp;quot;&amp;quot;获取打包后资源文件的绝对路径&amp;quot;&amp;quot;&amp;quot;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&amp;nbsp;hasattr(sys,&amp;nbsp;&amp;#39;_MEIPASS&amp;#39;):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;如果是打包后的环境&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;base_path&amp;nbsp;=&amp;nbsp;sys._MEIPASS
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;开发环境，直接使用当前路径
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;base_path&amp;nbsp;=&amp;nbsp;os.path.abspath(&amp;quot;.&amp;quot;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;os.path.join(base_path,&amp;nbsp;relative_path)


with&amp;nbsp;open(resource_path(&amp;#39;data/config.json&amp;#39;))&amp;nbsp;as&amp;nbsp;file:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;a&amp;nbsp;=&amp;nbsp;file.read()

print(a)&lt;/pre&gt;&lt;/div&gt;&lt;h3 style=&quot;font-style: inherit; font-variant: inherit; font-stretch: inherit; font-size: 1.1em; line-height: 1.5; font-family: inherit; font-optical-sizing: inherit; font-kerning: inherit; font-feature-settings: inherit; font-variation-settings: inherit; margin: calc(1.90909em) 0px calc(1.27273em); clear: left;&quot;&gt;8. 生成 Spec 文件进行定制&lt;/h3&gt;&lt;p data-pid=&quot;wF_EkPl3&quot; style=&quot;margin-top: 1.4em; margin-bottom: 1.4em;&quot;&gt;Spec 文件是 PyInstaller 打包的配置文件，默认情况下，PyInstaller 在每次打包时自动生成一个&amp;nbsp;&lt;code style=&quot;background-color: rgb(248, 248, 250); border-radius: 3px; font-family: Menlo, Monaco, Consolas, &amp;quot;Andale Mono&amp;quot;, &amp;quot;lucida console&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.9em; margin: 0px 2px; padding: 3px 4px;&quot;&gt;.spec&lt;/code&gt;&amp;nbsp;文件。你可以手动生成或编辑这个文件以实现更高级的配置。&lt;/p&gt;&lt;p data-pid=&quot;FzU9v_gQ&quot; style=&quot;margin-top: 1.4em; margin-bottom: 1.4em;&quot;&gt;生成 Spec 文件的命令：&lt;/p&gt;&lt;div class=&quot;highlight&quot; style=&quot;margin: 1em 0px;&quot;&gt;&lt;pre style=&quot;margin-top: 0px; margin-bottom: 0px; overflow-wrap: initial; background-color: rgb(248, 248, 250); border-radius: 4px; font-size: 0.9em; overflow: auto; padding: calc(0.888889em); word-break: initial;&quot;&gt;pyinstaller&amp;nbsp;--onefile&amp;nbsp;--add-data&amp;nbsp;&amp;quot;data/config.json;data&amp;quot;&amp;nbsp;--add-data&amp;nbsp;&amp;quot;assets/app.ico;assets&amp;quot;&amp;nbsp;--icon=assets/app.ico&amp;nbsp;--name&amp;nbsp;my_app_name&amp;nbsp;main.py&amp;nbsp;--specpath&amp;nbsp;.&lt;/pre&gt;&lt;/div&gt;&lt;p data-pid=&quot;c2WB1McW&quot; style=&quot;margin-top: 1.4em; margin-bottom: 1.4em;&quot;&gt;生成 Spec 文件后，你可以根据需要编辑其中的设置，然后通过以下命令再次打包：&lt;/p&gt;&lt;div class=&quot;highlight&quot; style=&quot;margin: 1em 0px;&quot;&gt;&lt;pre style=&quot;margin-top: 0px; margin-bottom: 0px; overflow-wrap: initial; background-color: rgb(248, 248, 250); border-radius: 4px; font-size: 0.9em; overflow: auto; padding: calc(0.888889em); word-break: initial;&quot;&gt;pyinstaller&amp;nbsp;my_app_name.spec&lt;/pre&gt;&lt;/div&gt;&lt;h3 style=&quot;font-style: inherit; font-variant: inherit; font-stretch: inherit; font-size: 1.1em; line-height: 1.5; font-family: inherit; font-optical-sizing: inherit; font-kerning: inherit; font-feature-settings: inherit; font-variation-settings: inherit; margin: calc(1.90909em) 0px calc(1.27273em); clear: left;&quot;&gt;9. 常见问题&lt;/h3&gt;&lt;h3 style=&quot;font-style: inherit; font-variant: inherit; font-stretch: inherit; font-size: 1.1em; line-height: 1.5; font-family: inherit; font-optical-sizing: inherit; font-kerning: inherit; font-feature-settings: inherit; font-variation-settings: inherit; margin: calc(1.90909em) 0px calc(1.27273em); clear: left;&quot;&gt;文件路径找不到&lt;/h3&gt;&lt;ul style=&quot;list-style-type: none;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;•&amp;nbsp;&lt;span style=&quot;font-weight: 600;&quot;&gt;问题原因：&lt;/span&gt;&amp;nbsp;打包后的可执行文件运行时，文件路径会变为临时路径&lt;svg width=&quot;10px&quot; height=&quot;10px&quot; viewbox=&quot;0 0 16 16&quot; class=&quot;ZDI ZDI--FourPointedStar16 css-1dvsrp&quot; fill=&quot;currentColor&quot;&gt;&lt;path d=&quot;m5.068 9.267-3.08-.77a.512.512 0 0 1 0-.994l3.08-.77a2.289 2.289 0 0 0 1.665-1.665l.77-3.08a.512.512 0 0 1 .994 0l.77 3.08c.205.82.845 1.46 1.665 1.665l3.08.77a.512.512 0 0 1 0 .994l-3.08.77a2.29 2.29 0 0 0-1.665 1.665l-.77 3.08a.512.512 0 0 1-.994 0l-.77-3.08a2.289 2.289 0 0 0-1.665-1.665Z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;a class=&quot;RichContent-EntityWord css-b7erz1&quot; data-za-not-track-link=&quot;true&quot; data-paste-text=&quot;true&quot; href=&quot;https://zhida.zhihu.com/search?content_id=251875255&amp;content_type=Article&amp;match_order=1&amp;q=%E4%B8%B4%E6%97%B6%E8%B7%AF%E5%BE%84&amp;zhida_source=entity&quot; target=&quot;_blank&quot; style=&quot;text-decoration-line: none; color: rgb(9, 64, 142); cursor: pointer;&quot;&gt;&lt;svg width=&quot;10px&quot; height=&quot;10px&quot; viewbox=&quot;0 0 16 16&quot; class=&quot;ZDI ZDI--FourPointedStar16 css-1dvsrp&quot; fill=&quot;currentColor&quot;&gt;&lt;path d=&quot;m5.068 9.267-3.08-.77a.512.512 0 0 1 0-.994l3.08-.77a2.289 2.289 0 0 0 1.665-1.665l.77-3.08a.512.512 0 0 1 .994 0l.77 3.08c.205.82.845 1.46 1.665 1.665l3.08.77a.512.512 0 0 1 0 .994l-3.08.77a2.29 2.29 0 0 0-1.665 1.665l-.77 3.08a.512.512 0 0 1-.994 0l-.77-3.08a2.289 2.289 0 0 0-1.665-1.665Z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;，直接使用相对路径可能会找不到文件。&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;•&amp;nbsp;&lt;span style=&quot;font-weight: 600;&quot;&gt;解决方案：&lt;/span&gt;&amp;nbsp;使用&amp;nbsp;&lt;code style=&quot;background-color: rgb(248, 248, 250); border-radius: 3px; font-family: Menlo, Monaco, Consolas, &amp;quot;Andale Mono&amp;quot;, &amp;quot;lucida console&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.9em; margin: 0px 2px; padding: 3px 4px;&quot;&gt;sys._MEIPASS&lt;/code&gt;&amp;nbsp;定位打包后的临时目录，确保文件路径正确。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 style=&quot;font-style: inherit; font-variant: inherit; font-stretch: inherit; font-size: 1.1em; line-height: 1.5; font-family: inherit; font-optical-sizing: inherit; font-kerning: inherit; font-feature-settings: inherit; font-variation-settings: inherit; margin: calc(1.90909em) 0px calc(1.27273em); clear: left;&quot;&gt;打包后的文件过大&lt;/h3&gt;&lt;ul style=&quot;list-style-type: none;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;•&amp;nbsp;&lt;span style=&quot;font-weight: 600;&quot;&gt;问题原因：&lt;/span&gt;&amp;nbsp;PyInstaller 会将所有依赖库打包进可执行文件，导致文件较大。&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;•&amp;nbsp;&lt;span style=&quot;font-weight: 600;&quot;&gt;解决方案：&lt;/span&gt;&amp;nbsp;可以通过&amp;nbsp;&lt;code style=&quot;background-color: rgb(248, 248, 250); border-radius: 3px; font-family: Menlo, Monaco, Consolas, &amp;quot;Andale Mono&amp;quot;, &amp;quot;lucida console&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.9em; margin: 0px 2px; padding: 3px 4px;&quot;&gt;--exclude-module&lt;/code&gt;&amp;nbsp;参数排除不需要的模块，或使用&amp;nbsp;&lt;code style=&quot;background-color: rgb(248, 248, 250); border-radius: 3px; font-family: Menlo, Monaco, Consolas, &amp;quot;Andale Mono&amp;quot;, &amp;quot;lucida console&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.9em; margin: 0px 2px; padding: 3px 4px;&quot;&gt;--onefile&lt;/code&gt;&amp;nbsp;选项减少冗余文件。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 style=&quot;font-style: inherit; font-variant: inherit; font-stretch: inherit; font-size: 1.1em; line-height: 1.5; font-family: inherit; font-optical-sizing: inherit; font-kerning: inherit; font-feature-settings: inherit; font-variation-settings: inherit; margin: calc(1.90909em) 0px calc(1.27273em); clear: left;&quot;&gt;运行时出现缺少依赖&lt;/h3&gt;&lt;ul style=&quot;list-style-type: none;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;•&amp;nbsp;&lt;span style=&quot;font-weight: 600;&quot;&gt;问题原因：&lt;/span&gt;&amp;nbsp;PyInstaller 在某些情况下无法自动检测到所有依赖项。&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;•&amp;nbsp;&lt;span style=&quot;font-weight: 600;&quot;&gt;解决方案：&lt;/span&gt;&amp;nbsp;使用&amp;nbsp;&lt;code style=&quot;background-color: rgb(248, 248, 250); border-radius: 3px; font-family: Menlo, Monaco, Consolas, &amp;quot;Andale Mono&amp;quot;, &amp;quot;lucida console&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.9em; margin: 0px 2px; padding: 3px 4px;&quot;&gt;hidden-import&lt;/code&gt;&amp;nbsp;选项手动指定依赖模块，例如：&lt;br data-filtered=&quot;filtered&quot;/&gt;pyinstaller --onefile --hidden-import module_name main.py&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 style=&quot;font-style: inherit; font-variant: inherit; font-stretch: inherit; font-size: 1.1em; line-height: 1.5; font-family: inherit; font-optical-sizing: inherit; font-kerning: inherit; font-feature-settings: inherit; font-variation-settings: inherit; margin: calc(1.90909em) 0px calc(1.27273em); clear: left;&quot;&gt;10. 总结&lt;/h3&gt;&lt;p data-pid=&quot;sgtL-uMb&quot; style=&quot;margin-top: 1.4em; margin-bottom: 1.4em;&quot;&gt;使用 PyInstaller 打包 Python 项目，可以轻松地将 Python 程序转换为独立可执行文件，便于分发。通过结合&amp;nbsp;&lt;code style=&quot;background-color: rgb(248, 248, 250); border-radius: 3px; font-family: Menlo, Monaco, Consolas, &amp;quot;Andale Mono&amp;quot;, &amp;quot;lucida console&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.9em; margin: 0px 2px; padding: 3px 4px;&quot;&gt;--onefile&lt;/code&gt;、&lt;code style=&quot;background-color: rgb(248, 248, 250); border-radius: 3px; font-family: Menlo, Monaco, Consolas, &amp;quot;Andale Mono&amp;quot;, &amp;quot;lucida console&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.9em; margin: 0px 2px; padding: 3px 4px;&quot;&gt;--add-data&lt;/code&gt;、&lt;code style=&quot;background-color: rgb(248, 248, 250); border-radius: 3px; font-family: Menlo, Monaco, Consolas, &amp;quot;Andale Mono&amp;quot;, &amp;quot;lucida console&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.9em; margin: 0px 2px; padding: 3px 4px;&quot;&gt;--icon&lt;/code&gt;&amp;nbsp;等参数，你可以打包多模块的项目，添加图标和资源文件，并确保打包后应用能够正确读取这些文件。&lt;/p&gt;&lt;p data-pid=&quot;DnBDAixw&quot; style=&quot;margin-top: 1.4em; margin-bottom: 0px;&quot;&gt;通过本文介绍的打包步骤和细节处理方法，你可以更好地管理打包过程，优化打包后的文件大小，并解决常见的打包问题。&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;</description><pubDate>Sat, 11 Jan 2025 15:47:53 +0800</pubDate></item><item><title>zblog二级域名安装伪静态设置</title><link>https://www.tuiedu.org/131.html</link><description>&lt;p&gt;&amp;nbsp; &amp;nbsp; 在二级目录安装完zblog后，二级目录的伪静态会失效。下面给出解决方法。&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; 将以下代码，复制到伪静态规则中。注意代码中baike修改为你自己的二级目录，比如你zblog安装的二级目录是news，就需要把代码中baike改成news即可。&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; 打开宝塔站点设置---伪静态----复制修改好的伪静态规则进去。如果是虚拟主机可以放到.htaccess文件中。&lt;/p&gt;&lt;p&gt;&lt;img class=&quot;ue-image&quot; src=&quot;https://www.tuiedu.org/zb_users/upload/2025/01/202501081736315690238123.jpg&quot; title=&quot;1736315667324.jpg&quot; alt=&quot;1736315667324.jpg&quot;/&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; 完整伪静态规则：&lt;/p&gt;&lt;pre class=&quot;prism-highlight prism-language-perl&quot;&gt;location&amp;nbsp;/baike/&amp;nbsp;{
if&amp;nbsp;(-f&amp;nbsp;$request_filename/index.html)&amp;nbsp;{
rewrite&amp;nbsp;(.*)&amp;nbsp;$1/index.html&amp;nbsp;break;
}
if&amp;nbsp;(-f&amp;nbsp;$request_filename/index.php)&amp;nbsp;{
rewrite&amp;nbsp;(.*)&amp;nbsp;$1/index.php;
}
if&amp;nbsp;(!-f&amp;nbsp;$request_filename)&amp;nbsp;{
rewrite&amp;nbsp;(.*)&amp;nbsp;/baike/index.php;
}
}

location&amp;nbsp;/&amp;nbsp;{
if&amp;nbsp;(-f&amp;nbsp;$request_filename/index.html)&amp;nbsp;{
rewrite&amp;nbsp;(.*)&amp;nbsp;$1/index.html&amp;nbsp;break;
}
if&amp;nbsp;(-f&amp;nbsp;$request_filename/index.php)&amp;nbsp;{
rewrite&amp;nbsp;(.*)&amp;nbsp;$1/index.php;
}
if&amp;nbsp;(!-f&amp;nbsp;$request_filename)&amp;nbsp;{
rewrite&amp;nbsp;(.*)&amp;nbsp;/index.php;
}
}&lt;/pre&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;</description><pubDate>Wed, 08 Jan 2025 13:50:10 +0800</pubDate></item><item><title>一行代码禁止wordpress自动更新</title><link>https://www.tuiedu.org/129.html</link><description>&lt;p&gt;把代码加入到wp-config.php文件底部就可以了。如果又想让wp自动更新了，那就把这个代码删除或者注释掉。&lt;/p&gt;&lt;pre class=&quot;prism-highlight prism-language-php&quot;&gt;define(&amp;nbsp;&amp;#39;WP_AUTO_UPDATE_CORE&amp;#39;,&amp;nbsp;false&amp;nbsp;);&lt;/pre&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;</description><pubDate>Thu, 15 Aug 2024 17:26:12 +0800</pubDate></item><item><title>wordpress屏蔽某个国家访问代码</title><link>https://www.tuiedu.org/128.html</link><description>&lt;pre class=&quot;prism-highlight prism-language-php&quot;&gt;为什么要用代码？因为插件装多了wordpress会慢，而且很多插件也不太好用。

function&amp;nbsp;block_countries(){
&amp;nbsp;&amp;nbsp;$location&amp;nbsp;=&amp;nbsp;WC_Geolocation::geolocate_ip();
&amp;nbsp;&amp;nbsp;$country&amp;nbsp;=&amp;nbsp;$location[&amp;#39;country&amp;#39;];
&amp;nbsp;&amp;nbsp;$blocked_countries&amp;nbsp;=&amp;nbsp;array(&amp;#39;CN&amp;#39;,&amp;#39;US&amp;#39;);&amp;nbsp;//&amp;nbsp;这里列出你想要屏蔽的国家代码，可以根据需要添加或修改
&amp;nbsp;&amp;nbsp;if&amp;nbsp;(&amp;nbsp;in_array($country,&amp;nbsp;$blocked_countries)&amp;nbsp;){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;wp_die(&amp;#39;抱歉，本站暂不对您的国家开放访问！&amp;#39;);
&amp;nbsp;&amp;nbsp;}
}
add_action(&amp;#39;wp_head&amp;#39;,&amp;#39;block_countries&amp;#39;);&lt;/pre&gt;&lt;p&gt;&lt;span style=&quot;color: #777777; font-family: Poppins, sans-serif; text-wrap: wrap; background-color: #FFFFFF;&quot;&gt;将上边的代码添加到后台的外观-主题文件编辑器-functions.php文件。&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: #777777; font-family: Poppins, sans-serif; text-wrap: wrap; background-color: #FFFFFF;&quot;&gt;上边的代码默认屏蔽了中国和美国，如果你想屏蔽其他国家，只需要填写其他国家的代码就可以了&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color:#777777;font-family:Poppins, sans-serif&quot;&gt;&lt;span style=&quot;background-color: #FFFFFF;&quot;&gt;还有要注意的是，这个代码是基于本身你的wordpress安装了Woocommerce插件才能实现的。&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color:#777777;font-family:Poppins, sans-serif&quot;&gt;&lt;span style=&quot;background-color: #FFFFFF;&quot;&gt;如果你没安装woocommerce插件，那就需要用到一下代码了。&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color:#777777;font-family:Poppins, sans-serif&quot;&gt;&lt;span style=&quot;background-color: #FFFFFF;&quot;&gt;将下面的代码添加到wordpress后台的外观-主题文件编辑器-functions.php文件：&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;pre class=&quot;prism-highlight prism-language-php&quot;&gt;function&amp;nbsp;ip_info($ip&amp;nbsp;=&amp;nbsp;NULL,&amp;nbsp;$purpose&amp;nbsp;=&amp;nbsp;&amp;quot;location&amp;quot;,&amp;nbsp;$deep_detect&amp;nbsp;=&amp;nbsp;TRUE)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;$output&amp;nbsp;=&amp;nbsp;NULL;
&amp;nbsp;&amp;nbsp;if&amp;nbsp;(filter_var($ip,&amp;nbsp;FILTER_VALIDATE_IP)&amp;nbsp;===&amp;nbsp;FALSE)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$ip&amp;nbsp;=&amp;nbsp;$_SERVER[&amp;quot;REMOTE_ADDR&amp;quot;];
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&amp;nbsp;($deep_detect)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&amp;nbsp;(filter_var(@$_SERVER[&amp;#39;HTTP_X_FORWARDED_FOR&amp;#39;],&amp;nbsp;FILTER_VALIDATE_IP))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$ip&amp;nbsp;=&amp;nbsp;$_SERVER[&amp;#39;HTTP_X_FORWARDED_FOR&amp;#39;];
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&amp;nbsp;(filter_var(@$_SERVER[&amp;#39;HTTP_CLIENT_IP&amp;#39;],&amp;nbsp;FILTER_VALIDATE_IP))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$ip&amp;nbsp;=&amp;nbsp;$_SERVER[&amp;#39;HTTP_CLIENT_IP&amp;#39;];
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;$purpose&amp;nbsp;&amp;nbsp;=&amp;nbsp;str_replace(array(&amp;quot;name&amp;quot;,&amp;nbsp;&amp;quot;\n&amp;quot;,&amp;nbsp;&amp;quot;\t&amp;quot;,&amp;nbsp;&amp;quot;&amp;nbsp;&amp;quot;,&amp;nbsp;&amp;quot;-&amp;quot;,&amp;nbsp;&amp;quot;_&amp;quot;),&amp;nbsp;NULL,&amp;nbsp;strtolower(trim($purpose)));
&amp;nbsp;&amp;nbsp;$support&amp;nbsp;&amp;nbsp;=&amp;nbsp;array(&amp;quot;country&amp;quot;,&amp;nbsp;&amp;quot;countrycode&amp;quot;,&amp;nbsp;&amp;quot;state&amp;quot;,&amp;nbsp;&amp;quot;region&amp;quot;,&amp;nbsp;&amp;quot;city&amp;quot;,&amp;nbsp;&amp;quot;location&amp;quot;,&amp;nbsp;&amp;quot;address&amp;quot;);
&amp;nbsp;&amp;nbsp;$continents&amp;nbsp;=&amp;nbsp;array(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;AF&amp;quot;&amp;nbsp;=&amp;gt;&amp;nbsp;&amp;quot;Africa&amp;quot;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;AN&amp;quot;&amp;nbsp;=&amp;gt;&amp;nbsp;&amp;quot;Antarctica&amp;quot;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;AS&amp;quot;&amp;nbsp;=&amp;gt;&amp;nbsp;&amp;quot;Asia&amp;quot;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;EU&amp;quot;&amp;nbsp;=&amp;gt;&amp;nbsp;&amp;quot;Europe&amp;quot;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;OC&amp;quot;&amp;nbsp;=&amp;gt;&amp;nbsp;&amp;quot;Australia&amp;nbsp;(Oceania)&amp;quot;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;NA&amp;quot;&amp;nbsp;=&amp;gt;&amp;nbsp;&amp;quot;North&amp;nbsp;America&amp;quot;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;SA&amp;quot;&amp;nbsp;=&amp;gt;&amp;nbsp;&amp;quot;South&amp;nbsp;America&amp;quot;
&amp;nbsp;&amp;nbsp;);
&amp;nbsp;&amp;nbsp;if&amp;nbsp;(filter_var($ip,&amp;nbsp;FILTER_VALIDATE_IP)&amp;nbsp;&amp;amp;&amp;amp;&amp;nbsp;in_array($purpose,&amp;nbsp;$support))&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$ipdat&amp;nbsp;=&amp;nbsp;@json_decode(file_get_contents(&amp;quot;http://www.geoplugin.net/json.gp?ip=&amp;quot;&amp;nbsp;.&amp;nbsp;$ip));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&amp;nbsp;(@strlen(trim($ipdat-&amp;gt;geoplugin_countryCode))&amp;nbsp;==&amp;nbsp;2)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;switch&amp;nbsp;($purpose)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;case&amp;nbsp;&amp;quot;location&amp;quot;:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$output&amp;nbsp;=&amp;nbsp;array(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;city&amp;quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;=&amp;gt;&amp;nbsp;@$ipdat-&amp;gt;geoplugin_city,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;state&amp;quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;=&amp;gt;&amp;nbsp;@$ipdat-&amp;gt;geoplugin_regionName,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;country&amp;quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;=&amp;gt;&amp;nbsp;@$ipdat-&amp;gt;geoplugin_countryName,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;country_code&amp;quot;&amp;nbsp;&amp;nbsp;=&amp;gt;&amp;nbsp;@$ipdat-&amp;gt;geoplugin_countryCode,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;continent&amp;quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;=&amp;gt;&amp;nbsp;@$continents[strtoupper($ipdat-&amp;gt;geoplugin_continentCode)],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;continent_code&amp;quot;&amp;nbsp;=&amp;gt;&amp;nbsp;@$ipdat-&amp;gt;geoplugin_continentCode
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;break;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;case&amp;nbsp;&amp;quot;address&amp;quot;:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$address&amp;nbsp;=&amp;nbsp;array($ipdat-&amp;gt;geoplugin_countryName);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&amp;nbsp;(@strlen($ipdat-&amp;gt;geoplugin_regionName)&amp;nbsp;&amp;gt;=&amp;nbsp;1)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$address[]&amp;nbsp;=&amp;nbsp;$ipdat-&amp;gt;geoplugin_regionName;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&amp;nbsp;(@strlen($ipdat-&amp;gt;geoplugin_city)&amp;nbsp;&amp;gt;=&amp;nbsp;1)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$address[]&amp;nbsp;=&amp;nbsp;$ipdat-&amp;gt;geoplugin_city;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$output&amp;nbsp;=&amp;nbsp;implode(&amp;quot;,&amp;nbsp;&amp;quot;,&amp;nbsp;array_reverse($address));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;break;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;case&amp;nbsp;&amp;quot;city&amp;quot;:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$output&amp;nbsp;=&amp;nbsp;@$ipdat-&amp;gt;geoplugin_city;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;break;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;case&amp;nbsp;&amp;quot;state&amp;quot;:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$output&amp;nbsp;=&amp;nbsp;@$ipdat-&amp;gt;geoplugin_regionName;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;break;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;case&amp;nbsp;&amp;quot;region&amp;quot;:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$output&amp;nbsp;=&amp;nbsp;@$ipdat-&amp;gt;geoplugin_regionName;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;break;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;case&amp;nbsp;&amp;quot;country&amp;quot;:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$output&amp;nbsp;=&amp;nbsp;@$ipdat-&amp;gt;geoplugin_countryName;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;break;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;case&amp;nbsp;&amp;quot;countrycode&amp;quot;:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$output&amp;nbsp;=&amp;nbsp;@$ipdat-&amp;gt;geoplugin_countryCode;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;break;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;return&amp;nbsp;$output;
}

function&amp;nbsp;block_cn(){
&amp;nbsp;&amp;nbsp;&amp;nbsp;$block_cn&amp;nbsp;=&amp;nbsp;ip_info($ip,&amp;nbsp;&amp;quot;Country&amp;quot;);
&amp;nbsp;&amp;nbsp;&amp;nbsp;//echo&amp;nbsp;$ip;
&amp;nbsp;&amp;nbsp;&amp;nbsp;//echo&amp;nbsp;&amp;#39;&amp;lt;hr&amp;gt;&amp;#39;.$block_cn.&amp;#39;&amp;lt;hr&amp;gt;&amp;#39;;
&amp;nbsp;&amp;nbsp;&amp;nbsp;if($block_cn&amp;nbsp;==&amp;nbsp;&amp;#39;China&amp;#39;){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;wp_die(&amp;#39;本站不对中国访客开放！&amp;#39;);
&amp;nbsp;&amp;nbsp;&amp;nbsp;}
}
add_action(&amp;#39;wp_head&amp;#39;,&amp;#39;block_cn&amp;#39;);&lt;/pre&gt;&lt;p&gt;&lt;span style=&quot;color:#777777;font-family:Poppins, sans-serif&quot;&gt;&lt;span style=&quot;background-color: #FFFFFF;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color:#777777;font-family:Poppins, sans-serif&quot;&gt;&lt;span style=&quot;background-color: #FFFFFF;&quot;&gt;&lt;br/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color:#777777;font-family:Poppins, sans-serif&quot;&gt;&lt;span style=&quot;background-color: #FFFFFF;&quot;&gt;&lt;br/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;</description><pubDate>Thu, 15 Aug 2024 17:18:58 +0800</pubDate></item><item><title>php跳转代码，第四版（已测）</title><link>https://www.tuiedu.org/127.html</link><description>&lt;p&gt;蜘蛛访问，显示正常内容。用户访问跳转到对应网站，支持百度，搜狗，谷歌，必应，有道等常见搜索引擎。代码已测！&lt;/p&gt;&lt;p class=&quot;ue-upload&quot; style=&quot;line-height: 16px;&quot;&gt;&lt;img style=&quot;vertical-align: middle; margin-right: 2px;&quot; src=&quot;https://www.tuiedu.org/zb_system/image/filetype/rar.png&quot;/&gt;&lt;a style=&quot;font-size:12px; color:#0066cc;&quot; href=&quot;https://www.tuiedu.org/zb_users/upload/2023/09/202309141694686394710249.rar&quot; title=&quot;tz(4).rar&quot;&gt;tz(4).rar&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;</description><pubDate>Thu, 14 Sep 2023 18:09:33 +0800</pubDate></item><item><title>[已测]office/windows全版本激活工具HEU-KMS-Activator</title><link>https://www.tuiedu.org/126.html</link><description>&lt;p&gt;一直用HEU-KMS-Activator激活自己的windows和office，今天发现了个最新版本，分享下。&lt;/p&gt;&lt;p&gt;注意：使用的时候请关闭杀毒软件，否则会报警导致office激活失效。&lt;/p&gt;&lt;p&gt;以下是自己激活成功(2022年7月22号)的截图：&lt;/p&gt;&lt;p&gt;&lt;img class=&quot;ue-image&quot; src=&quot;https://www.tuiedu.org/zb_users/upload/2022/07/202207221658459489591157.jpg&quot; title=&quot;1658457152060.jpg&quot; alt=&quot;1658457152060.jpg&quot;/&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;软件下载地址：&lt;/p&gt;&lt;p&gt;解压密码：tuiedu&lt;/p&gt;&lt;p&gt;链接: https://pan.baidu.com/s/13mTAHWwDQYF7g200jAmOsQ?pwd=zfvm 提取码: zfvm&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;</description><pubDate>Fri, 22 Jul 2022 11:08:40 +0800</pubDate></item><item><title>centos7.X 防火墙规则</title><link>https://www.tuiedu.org/125.html</link><description>&lt;p&gt;&lt;/p&gt;&lt;p&gt;CentOS 7 防火墙设置及配置&lt;/p&gt;&lt;p&gt;1、查看firewall服务状态&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;systemctl status firewalld&lt;/p&gt;&lt;p&gt;2、查看firewall的状态&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;firewall-cmd --state&lt;/p&gt;&lt;p&gt;3、开启停止防火墙&lt;/p&gt;&lt;p&gt;开机启动：&lt;/p&gt;&lt;p&gt;systemctl enable firewalld.service&lt;/p&gt;&lt;p&gt;启动：&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;systemctl start firewalld.service&lt;/p&gt;&lt;p&gt;停止：&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;systemctl stop firewalld.service&lt;/p&gt;&lt;p&gt;禁止开机启动：&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;systemctl disable firewalld.service&lt;/p&gt;&lt;p&gt;4、开放端口&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;firewall-cmd --zone=public --add-port=80/tcp --permanent&lt;/p&gt;&lt;p&gt;–zone #作用域&lt;/p&gt;&lt;p&gt;–add-port=80/tcp #添加端口，格式为：端口号/协议&lt;/p&gt;&lt;p&gt;–permanent #永久生效，没有此参数重启后失效&lt;/p&gt;&lt;p&gt;5、禁用端口&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;firewall-cmd --zone=public --remove-port=80/tcp --permanent&lt;/p&gt;&lt;p&gt;6、应用修改(修改配置后要重启防火墙)&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;firewall-cmd --reload&lt;/p&gt;&lt;p&gt;7、查看所有开放的端口&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;firewall-cmd --zone=dmz --list-ports&lt;/p&gt;&lt;p&gt;firewall-cmd --list-ports&lt;/p&gt;&lt;p&gt;其它参数说明&lt;/p&gt;&lt;p&gt;1. firewall-cmd --state ##查看防火墙状态，是否是running&lt;/p&gt;&lt;p&gt;2. firewall-cmd --reload ##重新载入配置，比如添加规则之后，需要执行此命令&lt;/p&gt;&lt;p&gt;3. firewall-cmd --get-zones ##列出支持的zone&lt;/p&gt;&lt;p&gt;4. firewall-cmd --get-services ##列出支持的服务，在列表中的服务是放行的&lt;/p&gt;&lt;p&gt;5. firewall-cmd --query-service ftp ##查看ftp服务是否支持，返回yes或者no&lt;/p&gt;&lt;p&gt;6. firewall-cmd --add-service=ftp ##临时开放ftp服务&lt;/p&gt;&lt;p&gt;7. firewall-cmd --add-service=ftp --permanent ##永久开放ftp服务&lt;/p&gt;&lt;p&gt;8. firewall-cmd --remove-service=ftp --permanent ##永久移除ftp服务&lt;/p&gt;&lt;p&gt;9. iptables -L -n ##查看规则，这个命令是和iptables的相同的&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;8、查看防火墙规则&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;firewall-cmd --list-all&lt;/p&gt;&lt;p&gt;9、查询、开放、关闭端口&lt;/p&gt;&lt;p&gt;查询端口是否开放&lt;/p&gt;&lt;p&gt;firewall-cmd --query-port=8080/tcp&lt;/p&gt;&lt;p&gt;开放80端口&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;firewall-cmd --permanent --add-port=80/tcp&lt;/p&gt;&lt;p&gt;移除端口&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;firewall-cmd --permanent --remove-port=8080/tcp&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;</description><pubDate>Fri, 08 Apr 2022 13:54:31 +0800</pubDate></item><item><title>centos 查找大文件命令</title><link>https://www.tuiedu.org/124.html</link><description>&lt;p&gt;&amp;nbsp; &amp;nbsp; 最近推广学院（http://www.tuiedu.com）服务器的mysql突然无法启动了，进了shell&amp;nbsp;使用dh -f命令查询发现。硬盘使用100%。后来使用&lt;/p&gt;&lt;div&gt;&amp;nbsp;find&amp;nbsp;/&amp;nbsp;-size&amp;nbsp;+100M&amp;nbsp;|xargs&amp;nbsp;ls&amp;nbsp;-lh 命令查询文件发现，有个日志文件多到9个多G，过段删除。重启服务器，一切恢复正常。&lt;/div&gt;</description><pubDate>Mon, 05 Jul 2021 21:26:25 +0800</pubDate></item><item><title>分析美日贸易战后的日本，能给我们什么机会？</title><link>https://www.tuiedu.org/123.html</link><description>&lt;p&gt;&amp;nbsp; &amp;nbsp; 近期花费了一些时间分析了当年美日贸易站后的日本，发现历史总是惊人的相似。中国目前正在重演日本当年的情景。这篇文章我没有站在国家高度去分析，而是站在一个老百姓的角度去看待，希望能够管中窥豹，得到一点个人发展的方向。&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;img src=&quot;https://www.tuiedu.org/zb_users/upload/2021/06/202106101623316319600508.jpg&quot; title=&quot;1623316289(1).jpg&quot; alt=&quot;1623316289(1).jpg&quot; width=&quot;315&quot; height=&quot;231&quot; style=&quot;width: 315px; height: 231px;&quot;/&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; 先来聊下日本的一些简报：&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;1945年第二次世界大战，日本战败，美国趁虚而入，对日本进行非军事化改革。&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;1948年美国开始扶持日本，美日签订了《特许订货协议》，美国市场向日本开放。&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;1954—1958年为日本经济的高速增长阶段，仅用10年，日本经济恢复了战前水平。&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;20世纪70-80年代，美日贸易开始摩擦。在美国的威逼利诱下，日本签署了《广场协议》。90年代末，日本经济泡沫爆发，从此经济进入低迷时代。&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;有句老话叫做知历史，明事理。再来看看今天，是否可以看到一些熟悉的味道，先来说2点吧&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;1、当年日本经济形势好的时候，全球的奢饰品店几乎都是日本人在疯抢。这个和前几年中国大妈狂扫全球奢饰品和黄金没什么区别。&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 分析：这段时间，武井保雄成了日本首富，他的公司叫武富士公司。主要业务是放贷。当年日本人的消费习惯已经养成，没钱后仍然很多人保持原有的消费水平，于是大量的人开始借贷。现在看看国内所有的巨头，似乎早有察觉，几乎都在搞这个业务。腾讯、阿里、百度、抖音、360等，都在推自己的借贷业务。&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;2、日本经济泡沫爆发后，日本进入了低欲望社会，年轻人不再奋斗，选择躺平。躺平这个词是不是最近也很熟悉呢？&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 分析：虽然房地产，奢饰品等高消费行业都受到重创，但是日本的“娱乐产业”在这个时间却飞速增长。代表的有日本的：二次元动漫、宅男动画片、和很多爱情动作片。现在仍然看下国内，B站从2020年开始高速增长，现在已经是三个爱奇艺的市值了。原因是什么，相信你已经知道了。&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;最后我想说：乱世出英雄，任何时代只要把握好时机，机会总是有的！借用已经嫁到日本的志玲姐姐一句话结束这篇文章：加油，加油，加油！&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/p&gt;</description><pubDate>Thu, 10 Jun 2021 16:32:32 +0800</pubDate></item><item><title>干货：最新2021年百度霸屏技术分析</title><link>https://www.tuiedu.org/122.html</link><description>&lt;p&gt;&amp;nbsp; &amp;nbsp; 分析关键词：澳大利亚房产&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; 先来看效果：&lt;/p&gt;&lt;p&gt;&lt;img src=&quot;https://www.tuiedu.org/zb_users/upload/2021/03/202103151615777368730728.jpg&quot; title=&quot;201427y7cxvqxvqcr4wq02.jpg&quot; alt=&quot;201427y7cxvqxvqcr4wq02.jpg&quot; width=&quot;585&quot; height=&quot;1119&quot; style=&quot;width: 585px; height: 1119px;&quot;/&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;分析操作方法如下：&lt;/p&gt;&lt;h4&gt;&amp;nbsp; 第一：这属于泛站群。从下图中的文章列表中，我们可以看到，生成了大量的二级目录。文件列表如下:&lt;/h4&gt;&lt;p&gt;/Yj5hSS/063678.html&lt;/p&gt;&lt;p&gt;/w2pVCk/750555.html&lt;/p&gt;&lt;p&gt;....&lt;/p&gt;&lt;p&gt;/ro6uXw/394701.html&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;img src=&quot;https://www.tuiedu.org/zb_users/upload/2021/03/202103151615777482607575.png&quot; title=&quot;QQ图片20210315102441.png&quot; alt=&quot;QQ图片20210315102441.png&quot;/&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;很明显，这个属于泛二级目录的泛站群，镜像站只能拷贝某个站的整体结构。但是无法做到URL都在重写。&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;h4&gt;&amp;nbsp; &amp;nbsp; 第二：内容方面也属于泛站群的特征，内容中加入了ascii码，而且内容全都随机组合。如下图所示：&lt;/h4&gt;&lt;p&gt;&lt;img src=&quot;https://www.tuiedu.org/zb_users/upload/2021/03/202103151615777557758929.png&quot; title=&quot;QQ图片20210315102948.png&quot; alt=&quot;QQ图片20210315102948.png&quot;/&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; 第三：域名采用老域名，前期获得较好的信任度。可以在前期让搜索引擎快速收录网站。如下图所示：&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;img src=&quot;https://www.tuiedu.org/zb_users/upload/2021/03/202103151615777580578796.png&quot; title=&quot;QQ图片20210315103255.png&quot; alt=&quot;QQ图片20210315103255.png&quot; width=&quot;665&quot; height=&quot;337&quot; style=&quot;width: 665px; height: 337px;&quot;/&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; 第四：蜘蛛劫持，通过判断user-agent实现了蜘蛛看到的是个正常页面，而用户看到的却是跳转后的广告页面。&lt;/p&gt;&lt;p&gt;&lt;img src=&quot;https://www.tuiedu.org/zb_users/upload/2021/03/202103151615777631342228.png&quot; title=&quot;QQ图片20210315103718.png&quot; alt=&quot;QQ图片20210315103718.png&quot; width=&quot;754&quot; height=&quot;469&quot; style=&quot;width: 754px; height: 469px;&quot;/&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;第五：是否使用快排，因缺乏后台数据，无数据支撑，不敢乱下结论。或许用了。&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 上述方法实时成本如下：泛目录程序一套+香港多IP服务器一台+多个老域名+快排成本（？）=预计成本1万-2万左右&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 分析到这里吧，还有部分的技术比如快速收录之类的，就不在阐述了。原理都是想相通的。欢迎各路大神与我交流QQ:83298699&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;</description><pubDate>Mon, 15 Mar 2021 11:01:58 +0800</pubDate></item></channel></rss>