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执行重定向直接执行。这是更可靠的解决方案。



