Pass integer input argument for Popen.communicate()

前端 未结 3 452
走了就别回头了
走了就别回头了 2021-01-26 11:04

I am pretty new to python and I am stuck with something now. I am using python 2.7. I am trying to automate a command in shell for which I wrote a python script. I have to input

3条回答
  •  被撕碎了的回忆
    2021-01-26 11:27

    Finally I found the solution for this. Well the solution to this was pretty simple


    when I changed

    string = proc.communicate(input='2')

    to

    string = proc.communicate(input='2\n')

    it worked fine.

提交回复
热议问题