本文整理汇总了Python中ert.ecl.FortIO.writeRecord方法的典型用法代码示例。如果您正苦于以下问题:Python FortIO.writeRecord方法的具体用法?Python FortIO.writeRecord怎么用?Python FortIO.writeRecord使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ert.ecl.FortIO
的用法示例。
在下文中一共展示了FortIO.writeRecord方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_fortio_read_and_write
# 需要导入模块: from ert.ecl import FortIO [as 别名]
# 或者: from ert.ecl.FortIO import writeRecord [as 别名]
def test_fortio_read_and_write(self):
with TestAreaContext("python/fortio/read_and_write"):
f = FortIO("test", FortIO.WRITE_MODE)
record_size = 4000
for i, c in enumerate("abcdefghijklmnopqrstuvwxyz"):
data = bytearray(c * record_size)
f.writeRecord(data)
position = f.getPosition()
self.assertEqual(position, (i + 1) * (record_size + 8))
f = FortIO("test", FortIO.READ_MODE)
for c in "abcdefghijklmnopqrstuvwxyz":
record = f.readRecordAsString(record_size)
self.assertEqual(record, c * record_size)
示例2: test_fortio_read_and_write_and_rewrite
# 需要导入模块: from ert.ecl import FortIO [as 别名]
# 或者: from ert.ecl.FortIO import writeRecord [as 别名]
def test_fortio_read_and_write_and_rewrite(self):
with TestAreaContext("python/fortio/read_and_write_and_rewrite"):
record_size = 4000
f = FortIO("complete", FortIO.WRITE_MODE)
for c in "abcdefghijklmnopqrstuvwxyz":
data = bytearray(c * record_size)
f.writeRecord(data)
f = FortIO("test", FortIO.WRITE_MODE)
positions = {}
for c in "abcdefghij-lmnopqrstuvwxyz":
data = bytearray(c * record_size)
f.writeRecord(data)
positions[c] = f.getPosition()
f = FortIO("test", FortIO.READ_AND_WRITE_MODE)
f.seek(positions["j"])
new_data = bytearray("k" * record_size)
f.writeRecord(new_data)
f.close()
self.assertFilesAreEqual("test", "complete")