【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

相关推荐
薛少杰26 分钟前
Python异步系统学习路线第59讲_核心原理与实战案例详解【技巧】
python·事件循环·异步编程·实战案例·协程调度
一次旅行31 分钟前
fzf+ripgrep+fd终端三合一实战:一套检索工具链,大幅提升大型项目开发效率
人工智能·python·github
卷无止境35 分钟前
当代码要上线前,谁在替你把关?——Python安全审查的方法论与实践
后端·python
卷无止境42 分钟前
Python Dataclasses:让类定义回归简洁的艺术
后端·python
北冥you鱼1 小时前
Go语言数组越界处理机制详解:从编译时检查到运行时panic
java·python·golang
Python私教1 小时前
Django 做一个 AI 销售助手:读取客户记录,自动生成跟进计划
人工智能·python·django
LitchiCheng1 小时前
DGX Spark 进行 Comfyui 文生图,5秒一张图
人工智能·python
幻影123!10 小时前
从零训练一个会下五子棋的AI
python·深度学习·神经网络·强化学习·五子棋·alpha zero·mokugo
Python私教11 小时前
Django 接入 AI 大模型实战:从零做一个流式聊天网站
人工智能·python·django
Python私教11 小时前
Django 接入 MCP 实战:让 AI 安全调用数据库和业务接口
人工智能·python·django