成为Python砖家(1): 在本地查询Python HTML文档

目的

Python3 官方文档位于 https://docs.python.org/3/ , 有时候网络无法连接,或者连接速度慢, 这对于学习 Python 时的反馈造成了负面影响。准备一份本地 Python 文档可以让反馈更加及时。

下面给出 macOS 和 Win11 下的 Python 离线文档安装和查看方式。

macOS

本地是 macOS 系统。
在这里插入图片描述

下载 python html 格式文档
https://docs.python.org/3/download.html

下载logo png图像
https://www.python.org/community/logos/

创建 PythonDoc.sh, 用于创建 PythonDoc.app:

#!/bin/bash

# This script generates /Application/PythonDoc.app, which can be searched in launchpad
# You should have already downloaed Python HTML document from https://docs.python.org/3/download.html

mkdir -p ~/Applications/PythonDoc.app/Contents/MacOS
mkdir -p ~/Applications/PythonDoc.app/Contents/Resources

cat <<EOF > ~/Applications/PythonDoc.app/Contents/MacOS/PythonDoc
#!/bin/bash
open /Users/zz/Documents/python-3.12.5-docs-html/index.html
EOF

chmod +x ~/Applications/PythonDoc.app/Contents/MacOS/PythonDoc


cat <<EOF > ~/Applications/PythonDoc.app/Contents/Info.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleExecutable</key>
    <string>PythonDoc</string>
    <key>CFBundleIdentifier</key>
    <string>org.python.doc</string>
    <key>CFBundleName</key>
    <string>PythonDoc</string>
    <key>CFBundleVersion</key>
    <string>1.0</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleIconFile</key>
    <string>Python.icns</string>
</dict>
</plist>
EOF

cp python-logo-only.icns ~/Applications/PythonDoc.app/Contents/Resources/Python.icns

rm -rf /Applications/PythonDoc.app
mv ~/Applications/PythonDoc.app /Applications/

效果:在这里插入图片描述

在这里插入图片描述

在这里插入图片描述在这里插入图片描述

在这里插入图片描述

Win11

下载 Python html 格式文档: https://docs.python.org/3/download.html

解压到 D:/docs/python-3.12.5-docs-html 目录

进入 C:\ProgramData\Microsoft\Windows\Start Menu\Programs 目录, 创建 Python 目录

进入 D:/docs/python-3.12.5-docs-html 目录, 创建 index.html 的快捷方式,并剪切到 C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Python 目录, 重命名为 Python Documentation.html 文件:

在这里插入图片描述

进入开始菜单,输入 Python doc,可以看到创建的应用:
在这里插入图片描述
执行查询:
在这里插入图片描述

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值