【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

相关推荐
databook21 分钟前
Manim物理模拟:别自己写欧拉了!
python·数学·动效
香蕉鼠片2 小时前
Python进阶学习
开发语言·python
亚亚的学习和分享2 小时前
python练习:人生模拟器(简易版)
python
全糖可乐气泡水2 小时前
Codex适配国产信创环境安装部署与技术适配全解析
开发语言·git·python·算法·百度
LeocenaY3 小时前
搜集的一些测开面试题
开发语言·python
嗝o゚3 小时前
昇腾CANN ge 仓的图优化 Pass:哪些 Pass 真正影响推理性能
pytorch·python·深度学习·cann·ge-pass
深度先生3 小时前
Conda 全面讲解——数据科学家的标配工具
python
深度先生3 小时前
虚拟环境:别让包打架
python
漠效4 小时前
随机代理‌IP访问脚本
开发语言·python
SilentSamsara4 小时前
元类与 __init_subclass__:类是如何被“创建“出来的
开发语言·python·青少年编程