import os
res=os.popen('ipconfig')
dir(res)输出的方法是不全的,
可以明确res的类型是
<os._wrap_close at 0x2a0ddb7dcc0>
更明确的是
{'_stream': <_io.TextIOWrapper name=4 encoding='cp936'>, '_proc': <subprocess.Popen at 0x2a0ddbf89e8>, '__dir__': 1}
且该对象拥有read,readlines等io操作方法,但这些方法dir()无法获取到,但hasattr可以验证这些方法的存在。
抽象基类 | 继承 | 抽象方法 | Mixin方法和属性 |
---|---|---|---|
|
| ||
| 继承 | ||
| 继承 | ||
| 继承 |
更多关于该抽象基类的说明:
https://docs.python.org/zh-cn/3/library/io.html#io.TextIOWrapper