python - os.popen的返回对象没有__next__方法,为什么可以调用?
怪我咯
怪我咯 2017-04-18 09:48:50
0
1
845

我在使用os.popen方法的时候,返回了一个对象,但是通过dir()查看该方法并没有__next__()方法,然而却成功调用。代码如下:

>>> x = os.popen('ls')
>>> dir(x)
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__enter__', '__eq__', '__exit__',
 '__format__', '__ge__', '__getattr__', '__getattribute__', '__gt__', '__hash__', '__init__', 
'__iter__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', 
'__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_proc', 
'_stream', 'close']
>>> x.__next__()
'jobs\n'

使用的是python3,请问这是为什么?

怪我咯
怪我咯

走同样的路,发现不同的人生

모든 응답(1)
黄舟

이미 답을 찾았습니다:
http://stackoverflow.com/ques...

최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!