【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

相关推荐
Csvn30 分钟前
Python 开发技巧:标准库深度挖掘
后端·python
li星野1 小时前
二分查找的三重变奏:有序区间、旋转最小值与平方根——从“猜数字”到“向量检索”的思维演化
python
RSTJ_16251 小时前
PYTHON+AI LLM DAY ONE HUNDRED AND THREE
开发语言·人工智能·python
简~7682 小时前
python openpyxl处理Excel成绩表自动统计
python·大学生
梦想不只是梦与想2 小时前
Python 官方包管理器pip
python·pip
wahahaman3 小时前
基于GBDT的次日降水量预测实验
人工智能·python·机器学习·数据分析
Nontee3 小时前
数据类型与包装类 — 一个新手学Java的数据类型笔记
java·笔记·python
千天夜3 小时前
深入剖析 `Path(path).parent.mkdir(parents=True, exist_ok=True)` —— 优雅处理目录创建的终极方案
python
简~7684 小时前
python for in循环不能遍历整数怎么解决
python·大学生
aiqianji4 小时前
垂直专业的AI短篇小说写作软件有哪些特点?
人工智能·python