实验例子:os.popen 是什么类型的(object对象类型)
>>> I = os.popen('dir /B *.py')
>>> I
<os._wrap_close object at 0x0000000000B1A9B0>
实验例子:__next__()直接调用管道封装输出结果,
>>> I = os.popen('dir /B *.py')
>>> I.__next__()
'helloshell.py\n'
>>> I = os.popen('dir /B *.py')
>>> next(I)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: '_wrap_close' object is not an iterator
实验例子:iter() 就是for循环的行为
>>> I = os.popen('dir /B *.py')
>>> I = iter(I)
>>> I.__next__() # 输出结果
'helloshell.py\n'
>>> next(I) #next下一个文件名输出
'helloshell2.py\n'