How to call a Perl script from Python, piping input to it?

前端 未结 6 671
南方客
南方客 2021-01-01 01:21

I\'m hacking some support for DomainKeys and DKIM into an open source email marketing program, which uses a python script to send the actual emails via SMTP. I decided to go

6条回答
  •  长情又很酷
    2021-01-01 01:45

    from subprocess import Popen, PIPE
    p = Popen(['./foo.pl'], stdin=PIPE, stdout=PIPE)
    p.stdin.write(the_input)
    p.stdin.close()
    the_output = p.stdout.read()
    

提交回复
热议问题