【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

相关推荐
serve the people4 分钟前
tensorflow 零基础吃透:创建 tf.sparse.SparseTensor 的核心方法
人工智能·python·tensorflow
测试老哥6 分钟前
UI自动化测试—Jenkins配置优化
自动化测试·软件测试·python·测试工具·ui·jenkins·测试用例
曲幽7 分钟前
Python包管理告别龟速下载:uv工具国内镜像与离线安装实战
python·conda·pip·uv·venv·uvx
TsengOnce26 分钟前
阿里云ECS多版本JDK切换
java·python·阿里云
Hi_kenyon27 分钟前
FastAPI+VUE3创建一个项目的步骤模板(三)
python·fastapi
Flyora42 分钟前
【踩坑实录】PyInstaller 打包 “找不到库的完整解决方案
python
测试老哥42 分钟前
2026软件测试面试大全(含答案+文档)
自动化测试·软件测试·python·测试工具·面试·职场和发展·测试用例
yaoh.wang1 小时前
力扣(LeetCode) 28: 找出字符串中第一个匹配项的下标 - 解法思
python·程序人生·算法·leetcode·面试·职场和发展·跳槽
手揽回忆怎么睡1 小时前
win11灵活控制Python版本,使用pyenv-win
开发语言·python
唯唯qwe-1 小时前
Day20:贪心算法,跳跃游戏
python·算法·贪心算法