从Python运行Perl代码(输出到文件)

从Python运行Perl代码(输出到文件),第1张

从Python运行Perl代码(输出到文件)
subprocess.call("perl myCode.pl >results.txt", shell=True)

要么

subprocess.call(["sh", "-c", "perl myCode.pl >results.txt"])

要么

with open('results.txt', 'wb', 0) as file:    subprocess.call(["perl", "myCode.pl"], stdout=file)

前两个调用shell执行shell命令

perl myCode.pl >results.txt
。最后一个
perl
通过自己
call
执行重定向直接执行。这是更可靠的解决方案。



欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5668376.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-12-16
下一篇2022-12-16

发表评论

登录后才能评论

评论列表(0条)

    保存