微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在 Python 中没有 Premature 的 EOF 的情况下读取船长 proto 消息.bin 文件?

如何解决如何在 Python 中没有 Premature 的 EOF 的情况下读取船长 proto 消息.bin 文件?

我正在尝试读取 captian proto .bin 消息(以打包方式编写):

while

但它产生以下错误

timestep = []
with open('example.txt','r') as f:
    lines = f.readlines()
i = 0
while i < len(lines):
    if line[i].startswith("ITEM: timestep"):
       i += 1
       while not line[i].startswith("ITEM: "):
           timestep.append(next(line))     
           i += 1
    else:
       i += 1

为什么会出现这个错误?我假设我没有正确阅读打包的消息(或类似的东西)。如何在captain proto for python中正确打开这个文件内容

我阅读了以下链接,但没有帮助:

  1. Reading/writing Cap’n Proto messages partially
  2. How to set the Cap'n Proto RPC message traversal limit?
  3. https://github.com/capnproto/capnproto/issues/545
  4. https://jparyani.github.io/pycapnp/capnp.html#capnp._StructModule.read_packed

但他们并没有多大帮助。似乎很难在网上找到任何带有确切错误消息的内容dag_file = dag_api_capnp.Dag.read_packed(dependency_file,traversal_limit_in_words=2 ** 64 - 1) ,除了链接 4 似乎不太有用(并且没有提到 Python 一词)。

顺便说一句,这三个都会出错:

Traceback (most recent call last):
  File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydevd_bundle/pydevd_exec2.py",line 1,in Exec
    def Exec(exp,global_vars,local_vars=None):
  File "<input>",in <module>
  File "capnp/lib/capnp.pyx",line 3013,in capnp.lib.capnp._StructModule.read_packed
  File "capnp/lib/capnp.pyx",line 3600,in capnp.lib.capnp._PackedFdMessageReader.__init__
capnp.lib.capnp.KjException: kj/io.c++:53: Failed: expected n >= minBytes; Premature EOF
stack: 122b411e3 122b43536 122a48a97 108ca7d40 1229aa340 122a5a3d7 108c0fcf0 108c15396 108d64cf4 108d62abe 10a9f7f4c 108d5520a 108d4f728 108c6ef33 108d64cf4 108d62a04 10a9f7f4c 108d5520a 108c1117d 108d64cf4 108d62a04 10a9f7f4c 108c110c1 108d64cf4 108d616f9 10a9f7f4c 108c110c1 108d64cf4 108d61662 10a9f7f4c 108c110c1

交叉发布:https://github.com/capnproto/pycapnp/issues/257

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。