【Python】运行tcl、perl程序

只要你的环境可以执行tcl、perl脚本,也就是说安装了perl、tcl的解释器。那么python程序就可以执行tcl、perl。

示例:

python 复制代码
import subprocess

tcl_script_path = "D:\\Perl_WorkSpace\\test.tcl"
tcl_run_result = subprocess.run(['tclsh', tcl_script_path], capture_output=True, text=True)

print("tcl script output:\n", tcl_run_result.stdout)

if tcl_run_result.stderr:
    print("ERROR:", tcl_run_result.stderr)

perl_script_path = "D:\\Perl_WorkSpace\\TXT_COMPARE.pl"
perl_run_result = subprocess.run(['perl', perl_script_path], capture_output=True, text=True)

print("perl script output:\n", perl_run_result.stdout)

if perl_run_result.stderr:
    print("ERROR:", perl_run_result.stderr)

主要使用到了 subprocess模块。关于这个参考如下链接:

https://www.runoob.com/w3cnote/python3-subprocess.html

https://blog.51cto.com/u_16213402/11617608

相关推荐
Warson_L13 小时前
Python `Annotated` 与 LangGraph Reducer 学习笔记
python
韩师傅13 小时前
海天线算法的前世今生
python·计算机视觉
韩师傅13 小时前
当你的甲方设备过烂,要如何快速出效果?
python·计算机视觉
Warson_L13 小时前
LangGraph的MessageState and HumanMessage
python
韩师傅13 小时前
当你的甲方吐槽天空不够蓝,你应该如何应对
python·计算机视觉
Warson_L14 小时前
python的类&继承
python
Warson_L14 小时前
类型标注/type annotation
python
ThreeS16 小时前
手搓MiniVLA全实战教程-一步一步用pytorch解释原理与思路
人工智能·python
金銀銅鐵18 小时前
[Python] 模 n 乘法的逆元计算器
python·数学·游戏