Write a program to read and write the binary data using python?
Answer Posted / chaitanya
The module that is used to write and read the binary data is known as struct. This module allows the functionality and with it many functionalities to be used that consists of the string class. This class contains the binary data that is in the form of numbers that gets converted in python objects for use and vice versa. The program can read or write the binary data is:
import struct
f = open(file-name, "rb")
# This Open() method allows the file to get opened in binary mode to make it portable for # use.
s = f.read(8)
x, y, z = struct.unpack(">hhl", s)
The ‘>” is used to show the format string that allows the string to be converted in big-endian data form. For homogenous list of data the array module can be used that will allow the data to be kept more organized fashion.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
find max length of any given sublist?
What is unboundlocalerror in python?
What is the speciality of python?
How memcached should not be used in your python project?
Does python has private keyword in python ? How to make any variable private in python ?
Does python has any command to create variable?
What is use of list comprehension ?
What is the usage of help() function in python?
Can I create a website with Python?
How do I copy an object in python?
What are the applications of python?
Explain between deep and shallow copy?
What should be the typical build environment for python based application development?
What does unittest main () do?
What is nose python?