【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

相关推荐
smj2302_796826521 小时前
解决leetcode第3989题网格中保持一致的最大列数
python·算法·leetcode
吴梓穆2 小时前
Python 基础 正则表达式
python
巧克力男孩dd3 小时前
Python超典型练习题(第一次作业)
开发语言·python·算法
闲猫3 小时前
LangChain / Core components / Models
开发语言·python·langchain
cui_ruicheng6 小时前
Python从入门到实战(十三):模块、包与环境管理
开发语言·python
李宸净6 小时前
Web自动化测试selenium+python
前端·python·selenium
而后笑面对6 小时前
生信bwa算法
python
至乐活着8 小时前
深入Python内存管理与垃圾回收:从引用计数到分代回收的实战解析
python·性能优化·内存管理·垃圾回收·引用计数
m0_547486668 小时前
《Python数据分析与挖掘》全套PPT课件
python·数据挖掘·数据分析
㱘郳8 小时前
飞机大战Pygame存档
python·pygame