Python subprocess.Popen doesn't take text argument

我与影子孤独终老i 提交于 2020-02-24 10:45:48

问题


According to the Python 3 documentation for subprocess.Popen, the class constructor takes an optional argument text (which is supposed to control whether the file objects stdin, stdout and stderr are opened in text mode).

However, when I try setting text=true upon construction of a Popen object, I get the error

Failed: TypeError: __init__() got an unexpected keyword argument 'text'

and when I look in the source code (I'm using Python 3.6.4), the constructor takes no argument text. What is going on here? Why does the documentation say the constructor takes an optional argument text when it doesn't in the version of subprocess.py that I have?


回答1:


I have the feeling the text parameter has been added in 3.7, not 3.6.

Relevant part of the doc:

Changed in version 3.7: Added the text parameter, as a more understandable alias of universal_newlines. Added the capture_output parameter.



来源:https://stackoverflow.com/questions/52663518/python-subprocess-popen-doesnt-take-text-argument

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!