wps365 — WPS365 云文档 Python 绑定
WPS365 云文档工具(wps365-upload-rs)的 Python 绑定:基于 PyO3 将核心库编译为 CPython 扩展模块,提供云盘文件上传/下载/浏览/分享、智能文档创建、收藏、回收站、评论、标签等能力的同步 Python API。
CLI 与桌面 GUI 用法见仓库根 README,本页仅覆盖 Python 绑定。
安装(源码构建)
# 仓库根目录:uv 管理的 venv + maturin
uv venv .venv --python 3.13
uv pip install --python .venv maturin
# 构建并安装到 venv(editable,改 Rust 代码后重复执行即可)
cd crates/wps365-python
VIRTUAL_ENV=<仓库根>/.venv ../../.venv/Scripts/maturin develop
# 或只出分发物
uv build --wheel
快速上手
from wps365 import Client, Wps365Error
client = Client() # 凭据解析:构造参数 > 环境变量 > 配置文件
# client = Client(sid="V02S...") # 也可直接传入 wps_sid
for item in client.search("季度报告"):
print(item["name"], item["link_url"])
result = client.upload(r"D:\报告.xlsx", folder="项目文档", share=True)
info = client.download(result["file_id"], dest="./下载")
text = client.read(result["file_id"])["markdown"] # 在线文档抽取正文
Client 平铺全部 47 个方法(认证 / 云盘 / 文件 / 智能文档 / 搜索 / 收藏 / 回收站 / 评论 / 标签),完整签名见随包分发的 wps365.pyi(IDE 自动补全开箱可用)。所有方法为同步阻塞调用,执行期间释放 GIL;返回值为 openapi 原始响应序列化而来的 dict / list / str。
凭据
优先级(首个非空者生效):构造参数 sid > 环境变量 WPS_SID > wps_sid > COOKIE(解析其中 wps_sid 字段)> 配置文件 auth_state.wps_sid。
获取 wps_sid:浏览器登录 kdocs.cn → F12 → Application → Cookies → 复制 wps_sid 值。
错误处理
全部错误以 Wps365Error(Exception 子类)抛出,消息格式为「[机器错误码] 描述」,错误码与 CLI 一致(AUTH_EXPIRED_NO_SID / INVALID_PARAM / API_ERROR / IO_ERROR 等),可按前缀分支处理。
静态检查
- mypy / Pyright(Pylance):开箱即用,读取随包分发的
wps365.pyi。 - Pylint:默认不导入 C 扩展,会对
wps365.Client等成员误报no-member(E1101),需在使用方项目放行:
# 使用方项目的 pyproject.toml(或同目录 .pylintrc)
[tool.pylint.main]
extension-pkg-allow-list = ["wps365"]
测试
cd crates/wps365-python
../../.venv/Scripts/python.exe -m pytest tests/ -v # 离线冒烟
WPS365_PYTHON_LIVE=1 ../../.venv/Scripts/python.exe -m pytest tests/ -v # 含真实 API 用例
License
MIT
Metadata
Release files for wps365 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| wps365-0.4.0.tar.gz | 77.0 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| wps365-0.4.0-cp313-cp313-win_amd64.whl | CPython 3.13 | CPython 3.13 | Windows x86-64 | Details |
| wps365-0.4.0-cp312-cp312-win_amd64.whl | CPython 3.12 | CPython 3.12 | Windows x86-64 | Details |
| wps365-0.4.0-cp311-cp311-win_amd64.whl | CPython 3.11 | CPython 3.11 | Windows x86-64 | Details |
| wps365-0.4.0-cp310-cp310-win_amd64.whl | CPython 3.10 | CPython 3.10 | Windows x86-64 | Details |
| wps365-0.4.0-cp39-cp39-win_amd64.whl | CPython 3.9 | CPython 3.9 | Windows x86-64 | Details |
Total release size: 13.8 MB
Release files / wps365-0.4.0.tar.gz
| Download URL | wps365-0.4.0.tar.gz |
|---|---|
| Size | 77.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8cc796ef7459407888e977913cf1fcb9736791d2380b2b6dd0fade9ed60a3cf5
|
|
BLAKE2b-256 checksum How to use checksums |
2670057f70f3b37df51bd5e76d7c627922447690de28b85b62dfa93eb8a88469
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / wps365-0.4.0-cp313-cp313-win_amd64.whl
| Download URL | wps365-0.4.0-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 2.7 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
ba10632a0225682ae196a669195d2dfa86abfa1272bbb74102fb3234c5410148
|
|
BLAKE2b-256 checksum How to use checksums |
fc12515c21c906819550bfb834b6e8024c38ccc731384845586b8460bb2edf74
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / wps365-0.4.0-cp312-cp312-win_amd64.whl
| Download URL | wps365-0.4.0-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 2.7 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
fce29206f35029df962c9841f19d437233054f14973fe3025cf75cabde24bd67
|
|
BLAKE2b-256 checksum How to use checksums |
8b9dbca40b432ba418c72558678007a28cc35e2175dc8e1e5aeca428ab17e90c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / wps365-0.4.0-cp311-cp311-win_amd64.whl
| Download URL | wps365-0.4.0-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 2.7 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
c24eb2b19b4c1eeb22126b9b9d158844f06894bf3db73a1079f7fb5716392f5c
|
|
BLAKE2b-256 checksum How to use checksums |
e0972f333392b1c88bfd1684fa575951358bcf71a21c9c3da8113e93f7c464b2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / wps365-0.4.0-cp310-cp310-win_amd64.whl
| Download URL | wps365-0.4.0-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 2.7 MB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
a9a06b3ac9a5394e605f7d4349090167e6e48044c095bd8cdaa8d0c0fb9ea27c
|
|
BLAKE2b-256 checksum How to use checksums |
7d3a564eb9ddccd6a4c89d6d83c6c097cc3c692d0a17eb893779de639f7e9a48
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / wps365-0.4.0-cp39-cp39-win_amd64.whl
| Download URL | wps365-0.4.0-cp39-cp39-win_amd64.whl |
|---|---|
| Size | 2.7 MB |
| Tags | CPython 3.9 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
f2a2918b8e25458843f12793ac7bae472ed29707bbd24a6622f1ef92364196e0
|
|
BLAKE2b-256 checksum How to use checksums |
a104c46e7fa5c824b75f3170ea8dece40a470139b7f4eb98d38973fff326341c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|