gpt4 book ai didi

python - Pascal 类型化二进制文件的 C++ 和 Python 类似物

转载 作者:行者123 更新时间:2023-11-30 03:34:21 26 4
gpt4 key购买 nike

Pascal 中有一个方便的东西,那就是类型化的二进制文件。

来自 Free Pascal wiki 的描述

The type file of <type>, where <type> is any simple type (no references/pointers) or record type, is a binary file representing a sequence of values. For example, you can have files that are a sequence of integers, floating-point values, or records (as long as all record fields are also simple types).

我想知道我是否可以将类似的东西用于 Python 数据类型、C++ 类或类似 C 的普通结构,即用于比原始数字类型更复杂的东西。

最佳答案

Python(3) 基本上具有三种类型的文件;

  • 正文
  • 二进制
  • 原始

请参阅 io 的文档模块。

使用二进制文件和struct,您基本上可以在任意文件类型上创建迭代器。

关于python - Pascal 类型化二进制文件的 C++ 和 Python 类似物,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42120266/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com