Using structure module in Python What does ">ll" mean?!

Asked 2 years ago, Updated 2 years ago, 91 views

in the Python book

lbl_f = open("./mnist/" + name+ "-labels-idx1-ubyte","rb")
mag, lbl_count = struct.unpack(">ll", lbl_f.read(8))

I saw this phrase. But what does ">ll" mean? On the contrary, can we use <ll??

python struct

2022-09-22 19:34

1 Answers

First of all, you need to know why you use the structure.

Looking at the help

This module performs conversions between Python values and C structs represented as Python bytes objects.

It is said to perform a transformation between the Python and the structure of c.

In c, a structure is a kind of framework, and if you put a memory address into a structure, you can use it as a lump from the address to the size of the structure. (It's hard to write it easily and briefly.)

In other words, the structure module is used when dealing with binaries in Python.

> The symbol is Big Endian
l is unsigned int.

If it's Big Endian...The representative cpu is RISC series such as ARM and power cpu.

Intel IA-32 and others are Little Endians.

If you don't know Endian...Please refer to other books. That's too far from the question.


2022-09-22 19:34

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.