struct.pack

Does struct.pack(f'{len(x)}s', x) do anything at all?

Does struct.pack(f'{len(x)}s', x) do anything at all? Question: Consider the following code: import struct x = b’example’ # can be any bytes object y = struct.pack(f'{len(x)}s’, x) print(x == y) If I understand the documentation correctly, the function call will return the binary representation of a struct that has an array of len(x) chars (that …

Total answers: 1