请注意:
CPython:
PS Z:\dev\poc\SDR> python
Python 2.7.1 (r271:86832, Nov 27 2010, 17:19:03) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from zipfile import ZipFile
>>> z=ZipFile('d:/aaa.zip')
>>> input=z.open(z.namelist()[0])
>>> next(input)
'aaa,bbb\n'
>>> next(input)
'123,456\n'
>>>
铁蟒:
PS Z:\dev\poc\SDR> ipy64
IronPython 2.7.1 (2.7.0.40) on .NET 4.0.30319.225
Type "help", "copyright", "credits" or "license" for more information.
>>> from zipfile import ZipFile
>>> z=ZipFile('d:/aaa.zip')
>>> input=z.open(z.namelist()[0])
>>> next(input)
b'aaa,bbb\n'
>>> next(input)
'123,456\n'
>>>
请注意 IronPython 显示第一行,b'aaa,bbb\n'
而 CPython显示'aaa,bbb\n'
. 这种差异非常重要,因为前者只是字节,而后者是字符串。
如何让 IronPython 也将第一行视为字符串?