![](/img/trans.png)
[英]Forcing subprocess.Popen to write stdout/stderr to file-like object in python using write() function and not fileno()
[英]Python subprocess.Popen() and stdout file object association
我想知道subprocess.Popen()對象和stdout之間的關聯,以及它如何將Popen實例轉換為文件對象。
type(subprocess.Popen) # <type 'type'>
subprocess.Popen(":", shell=True).__class__ # <class 'subprocess.Popen'>
type(subprocess.Popen(":", shell=True, stdout=subprocess.PIPE).stdout) # <type 'file'>
但,
dir(subprocess.Popen)
沒有stdout作為其成員
stdout
是類Popen
一個屬性,其定義如下
self.stdout = None
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.