Hey guys is there a funtion in python that enables to output values to a bin files? Just like storing strings in .txt files, can we store hexadecimal values directly into .bin files? I am working using Python 2.7.3

Recommended Answers

All 4 Replies

look at this for an example. Basically, the key is in the open():

Modes 'r+', 'w+' and 'a+' open the file for updating (note that 'w+' truncates the file). Append 'b' to the mode to open the file in binary mode, on systems that differentiate between binary and text files; on systems that don’t have this distinction, adding the 'b' has no effect.

Thanks for the code @rrashkin. Is it possible to make a .bin file in place of a .dat file?

sure. It's just a name.

Alright. Thanks for the info!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.