playbook/docs/tsl/modules/tsl_python_interop.md

47 lines
1.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 天软平台和 Python 的交互
## 摘要
- 覆盖三类交互Python 调用 TSL、TSL 调用 Python、落地服务器开启 Python 服务。
- 提供 COM/远程登录两种路径,以及 `PyRun`/`PyCall` 体系。
## 结构索引
- 支持版本
- Python 调用 TSL配置步骤 / 接口说明 / 范例
- TSL 调用 Python配置步骤 / 接口说明 / 范例
- do Python 方式
- 落地服务器开启 Python 服务
- sklearn 机器学习接口
- 附录与 FAQ
## Python 调用 TSL核心步骤
1. 配置环境变量天软目录、Python 目录)。
2. 加载 TSLPy 模块(直接加载或修改包名)。
3. 选择连接方式COM / 远程登录)。
## 主要接口Python 侧)
- 服务器:`ConnectServer` / `LoginServer` / `Disconnect`
- 执行:`RemoteExecute` / `RemoteCallFunc`
- 系统参数:`SetSysParam` / `GetSysParam`
- 日期转换:`EncodeDate` / `DecodeDate` / `EncodeDateTime` / `DecodeDateTime`
## TSL 调用 Python核心接口
- `PyPutVar` / `PyGetVar`
- `PyRun`(执行脚本)
- `PyCall`(调用 Python 函数,支持命名参数)
- `PyError` / `PyRelease` / `PyEnsure`
## do Python 方式
- 适合快速执行 Python 脚本,省去显式接口调用。
## 注意事项(精简)
- Python 与 TSL 位数必须一致。
- 多版本 Python 需同步设置 `PYTHONHOME`
- TSL 调 Python 不支持网格调用。