formatting strings for stdin.write() in python 3.x

前端 未结 2 1033

I\'m having a problem where I get errors when I try to execute this code with python 3.2.2

working_file = subprocess.Popen([\"/pyRoot/iAmAProgram\"], stdout=         


        
2条回答
  •  臣服心动
    2021-01-17 17:28

    Is your error message "TypeError: 'str' does not support the buffer interface"? That error message tells you pretty much exactly what is wrong. You don't write string objects to that sdtin. So what do you write? Well, anything supporting the buffer interface. Typically this is bytes objects.

    Like:

    working_file.stdin.write(b'message')
    

提交回复
热议问题