本文整理汇总了Python中bz2.BZ2File.seek方法的典型用法代码示例。如果您正苦于以下问题:Python BZ2File.seek方法的具体用法?Python BZ2File.seek怎么用?Python BZ2File.seek使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bz2.BZ2File
的用法示例。
在下文中一共展示了BZ2File.seek方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testSeekForward
# 需要导入模块: from bz2 import BZ2File [as 别名]
# 或者: from bz2.BZ2File import seek [as 别名]
def testSeekForward(self):
# "Test BZ2File.seek(150, 0)"
self.createTempFile()
with BZ2File(self.filename) as bz2f:
self.assertRaises(TypeError, bz2f.seek)
bz2f.seek(150)
self.assertEqual(bz2f.read(), self.TEXT[150:])
示例2: testSeekBackwards
# 需要导入模块: from bz2 import BZ2File [as 别名]
# 或者: from bz2.BZ2File import seek [as 别名]
def testSeekBackwards(self):
# "Test BZ2File.seek(-150, 1)"
self.createTempFile()
with BZ2File(self.filename) as bz2f:
bz2f.read(500)
bz2f.seek(-150, 1)
self.assertEqual(bz2f.read(), self.TEXT[500-150:])
示例3: testSeekBackwardsFromEnd
# 需要导入模块: from bz2 import BZ2File [as 别名]
# 或者: from bz2.BZ2File import seek [as 别名]
def testSeekBackwardsFromEnd(self):
# "Test BZ2File.seek(-150, 2)"
self.createTempFile()
with BZ2File(self.filename) as bz2f:
bz2f.seek(-150, 2)
self.assertEqual(bz2f.read(), self.TEXT[len(self.TEXT)-150:])
示例4: testSeekPostEnd
# 需要导入模块: from bz2 import BZ2File [as 别名]
# 或者: from bz2.BZ2File import seek [as 别名]
def testSeekPostEnd(self):
# "Test BZ2File.seek(150000)"
self.createTempFile()
with BZ2File(self.filename) as bz2f:
bz2f.seek(150000)
self.assertEqual(bz2f.tell(), len(self.TEXT))
self.assertEqual(bz2f.read(), "")
示例5: testSeekPostEndTwice
# 需要导入模块: from bz2 import BZ2File [as 别名]
# 或者: from bz2.BZ2File import seek [as 别名]
def testSeekPostEndTwice(self):
# "Test BZ2File.seek(150000) twice"
self.createTempFile()
with BZ2File(self.filename) as bz2f:
bz2f.seek(150000)
bz2f.seek(150000)
self.assertEqual(bz2f.tell(), len(self.TEXT))
self.assertEqual(bz2f.read(), "")
示例6: testModeU
# 需要导入模块: from bz2 import BZ2File [as 别名]
# 或者: from bz2.BZ2File import seek [as 别名]
def testModeU(self):
# Bug #1194181: bz2.BZ2File opened for write with mode "U"
self.createTempFile()
bz2f = BZ2File(self.filename, "U")
bz2f.close()
f = file(self.filename)
f.seek(0, 2)
self.assertEqual(f.tell(), len(self.DATA))
f.close()
示例7: testSeekForward
# 需要导入模块: from bz2 import BZ2File [as 别名]
# 或者: from bz2.BZ2File import seek [as 别名]
def testSeekForward(self):
# "Test BZ2File.seek(150, 0)"
self.createTempFile()
bz2f = BZ2File(self.filename)
self.assertRaises(TypeError, bz2f.seek)
bz2f.seek(150)
self.assertEqual(bz2f.read(), self.TEXT[150:])
bz2f.close()
示例8: testSeekBackwards
# 需要导入模块: from bz2 import BZ2File [as 别名]
# 或者: from bz2.BZ2File import seek [as 别名]
def testSeekBackwards(self):
# "Test BZ2File.seek(-150, 1)"
self.createTempFile()
bz2f = BZ2File(self.filename)
bz2f.read(500)
bz2f.seek(-150, 1)
self.assertEqual(bz2f.read(), self.TEXT[500-150:])
bz2f.close()
示例9: testSeekBackwardsFromEnd
# 需要导入模块: from bz2 import BZ2File [as 别名]
# 或者: from bz2.BZ2File import seek [as 别名]
def testSeekBackwardsFromEnd(self):
# "Test BZ2File.seek(-150, 2)"
self.createTempFile()
bz2f = BZ2File(self.filename)
bz2f.seek(-150, 2)
self.assertEqual(bz2f.read(), self.TEXT[len(self.TEXT)-150:])
bz2f.close()
示例10: testSeekPostEnd
# 需要导入模块: from bz2 import BZ2File [as 别名]
# 或者: from bz2.BZ2File import seek [as 别名]
def testSeekPostEnd(self):
# "Test BZ2File.seek(150000)"
self.createTempFile()
bz2f = BZ2File(self.filename)
bz2f.seek(150000)
self.assertEqual(bz2f.tell(), len(self.TEXT))
self.assertEqual(bz2f.read(), "")
bz2f.close()
示例11: testSeekPostEndTwice
# 需要导入模块: from bz2 import BZ2File [as 别名]
# 或者: from bz2.BZ2File import seek [as 别名]
def testSeekPostEndTwice(self):
# "Test BZ2File.seek(150000) twice"
self.createTempFile()
bz2f = BZ2File(self.filename)
bz2f.seek(150000)
bz2f.seek(150000)
self.assertEqual(bz2f.tell(), len(self.TEXT))
self.assertEqual(bz2f.read(), "")
bz2f.close()