本文整理汇总了Python中bz2.BZ2File.readline方法的典型用法代码示例。如果您正苦于以下问题:Python BZ2File.readline方法的具体用法?Python BZ2File.readline怎么用?Python BZ2File.readline使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bz2.BZ2File
的用法示例。
在下文中一共展示了BZ2File.readline方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testReadLine
# 需要导入模块: from bz2 import BZ2File [as 别名]
# 或者: from bz2.BZ2File import readline [as 别名]
def testReadLine(self):
# "Test BZ2File.readline()"
self.createTempFile()
with BZ2File(self.filename) as bz2f:
self.assertRaises(TypeError, bz2f.readline, None)
sio = StringIO(self.TEXT)
for line in sio.readlines():
self.assertEqual(bz2f.readline(), line)
示例2: testMixedIterationReads
# 需要导入模块: from bz2 import BZ2File [as 别名]
# 或者: from bz2.BZ2File import readline [as 别名]
def testMixedIterationReads(self):
# Issue #8397: mixed iteration and reads should be forbidden.
with bz2.BZ2File(self.filename, 'wb') as f:
# The internal buffer size is hard-wired to 8192 bytes, we must
# write out more than that for the test to stop half through
# the buffer.
f.write(self.TEXT * 100)
with bz2.BZ2File(self.filename, 'rb') as f:
next(f)
self.assertRaises(ValueError, f.read)
self.assertRaises(ValueError, f.readline)
self.assertRaises(ValueError, f.readlines)
示例3: testReadLine
# 需要导入模块: from bz2 import BZ2File [as 别名]
# 或者: from bz2.BZ2File import readline [as 别名]
def testReadLine(self):
# "Test BZ2File.readline()"
self.createTempFile()
bz2f = BZ2File(self.filename)
self.assertRaises(TypeError, bz2f.readline, None)
sio = StringIO(self.TEXT)
for line in sio.readlines():
self.assertEqual(bz2f.readline(), line)
bz2f.close()