Course Hero Logo

docs_python_org_2_7_library_struct_html.pdf - Python »...

Course Hero uses AI to attempt to automatically extract content from documents to surface to you and others so you can study better, e.g., in search results, to enrich docs, and more. This preview shows page 1 - 4 out of 12 pages.

pdfcrowd.comopen in browserPRO versionAre you a developer? Try out theHTML to PDF APIindexmodules |next |previous |7.3.struct— Interpret strings aspacked binary dataThis module performs conversions between Python values and C structsrepresented as Python strings. This can be used in handling binary data storedin files or from network connections, among other sources. It usesFormatStringsas compact descriptions of the layout of the C structs and the intendedconversion to/from Python values.Note:By default, the result of packing a given C struct includes pad bytesin order to maintain proper alignment for the C types involved; similarly,alignment is taken into account when unpacking. This behavior is chosen sothat the bytes of a packed struct correspond exactly to the layout in memoryof the corresponding C struct. To handle platform-independent data formatsor omit implicit pad bytes, usestandardsize and alignment instead ofnativesize and alignment: seeByte Order, Size, and Alignmentfor details.7.3.1. Functions and ExceptionsThe module defines the following exception and functions:exceptionstruct.error«Python »2.7.6Documentation » The Python Standard Library » 7. StringServices »Table Of Contents7.3.struct— Interpretstrings as packed binarydata7.3.1. Functions andExceptions7.3.2. Format Strings7.3.2.1. ByteOrder, Size, andAlignment7.3.2.2. FormatCharacters7.3.2.3. Examples7.3.3. ClassesPrevious topic7.2.re— Regularexpression operationsNext topic7.4.difflib— Helpers forcomputing deltasThis PageReport a BugShow SourceQuick search
pdfcrowd.comopen in browserPRO versionAre you a developer? Try out theHTML to PDF APIException raised on various occasions; argument is a string describingwhat is wrong.struct.pack(fmt,v1,v2,...)Return a string containing the valuesv1, v2, ...packed according to thegiven format. The arguments must match the values required by the formatexactly.struct.pack_into(fmt,buffer,offset,v1,v2,...)Pack the valuesv1, v2, ...according to the given format, write thepacked bytes into the writablebufferstarting atoffset. Note that the offsetis a required argument.New in version 2.5.struct.unpack(fmt,string)Unpack the string (presumably packed bypack(fmt, ...)) according to thegiven format. The result is a tuple even if it contains exactly one item. Thestring must contain exactly the amount of data required by the format(len(string)must equalcalcsize(fmt)).struct.unpack_from(fmt,buffer[,offset=0])Unpack thebufferaccording to the given format. The result is a tuple evenif it contains exactly one item. Thebuffermust contain at least the amountof data required by the format (len(buffer[offset:])must be at leastcalcsize(fmt)).GoEnter search terms or a module,class or function name.
pdfcrowd.comopen in browserPRO versionAre you a developer? Try out theHTML to PDF APINew in version 2.5.

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 12 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Spring
Professor
N/A
Tags
Endianness, developer, Long integer, Short integer

Newly uploaded documents

Show More

Newly uploaded documents

Show More

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture