如何在 Python 脚本中获取 Perl 脚本的结果? [英] How can I get the results of a Perl script in Python script?

查看:65
本文介绍了如何在 Python 脚本中获取 Perl 脚本的结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Perl 中有一个脚本,另一个在 Python 中.我需要在Python中得到Perl的结果,然后给出最终报告.Perl 的结果可以是标量变量、散列变量或数组.

I have one script in Perl and the other in Python. I need to get the results of Perl in Python and then give the final report. The results from Perl can be scalar variable, hash variable, or an array.

请尽快通知我此事.

推荐答案

使用子流程 模块来运行您的 Perl 脚本以捕获其输出:

Use the subprocess module to run your Perl script to capture its output:

您可以在任一脚本中选择任何格式的输出格式,并使用 Python 打印最终报告.例如:您的 Perl 脚本可以输出 XML,该 XML 可由 Python 脚本解析,然后使用不同的格式打印.

You can format the output however you choose in either script, and use Python to print the final report. For example: your Perl script can output XML which can be parsed by the Python script and then printed using a different format.

这篇关于如何在 Python 脚本中获取 Perl 脚本的结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆