I’m new to Python, so I’m not sure how I should do this.
I have a list of strings to write to a file. Each string needs to be preceded by a 32bit integer equal to the length of the string.
I need to have all the data that’s going to be written to the file before I write it to the file. In C#, I would store everything in a byte array before writing, but I have no clue what to do in Python. Should I use a list, or is there a better data type? How should the information be stored?
edit: an example of what it would look like is:
00 00 00 04 74 65 73 74
the four bytes of an integer in big endian, followed by the string.
You can use lambda expressions to easily create a new list according to the strings and your formatting requirements, like: