zoukankan      html  css  js  c++  java
  • Interpret bytes as packed binary data

    7.1. struct — Interpret bytes as packed binary data — Python 3.6.5 documentation https://docs.python.org/3/library/struct.html

    ource code: Lib/struct.py


    This module performs conversions between Python values and C structs represented as Python bytes objects. This can be used in handling binary data stored in files or from network connections, among other sources. It uses Format Strings as compact descriptions of the layout of the C structs and the intended conversion to/from Python values.

    Note

     

    By default, the result of packing a given C struct includes pad bytes in order to maintain proper alignment for the C types involved; similarly, alignment is taken into account when unpacking. This behavior is chosen so that the bytes of a packed struct correspond exactly to the layout in memory of the corresponding C struct. To handle platform-independent data formats or omit implicit pad bytes, use standard size and alignment instead of nativesize and alignment: see Byte Order, Size, and Alignment for details.

    Several struct functions (and methods of Struct) take a buffer argument. This refers to objects that implement theBuffer Protocol and provide either a readable or read-writable buffer. The most common types used for that purpose are bytes and bytearray, but many other types that can be viewed as an array of bytes implement the buffer protocol, so that they can be read/filled without additional copying from a bytes object.

  • 相关阅读:
    刚体动力学
    碰撞检测系统
    动画系统II
    动画系统
    Game Develop Books
    光照技术
    LR参数组取值操作方法
    loadrunner测试ajax框架
    ​Web(click and script) 与 Web(HTTP/HTML)协议区别
    性能测试常用的linux命令
  • 原文地址:https://www.cnblogs.com/rsapaper/p/9146096.html
Copyright © 2011-2022 走看看