Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


Write a program to read and write the binary data using python?



Write a program to read and write the binary data using python?..

Answer / 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

More Python Interview Questions

Explain the uses of the modules sqlite3, ctypes, pickle, traceback, and itertools.

0 Answers  


What do you mean by python being an “interpreted language”?

0 Answers  


Can we use else with for loop in python?

0 Answers  


Write a command to convert a string into an int in python.

0 Answers  


What does defined by whitespace in python?

0 Answers  


Is python free or paid?

0 Answers  


What do you mean by overriding methods?

0 Answers  


How do you sort a list in ascending order in python?

0 Answers  


What do you mean by *args and **kwargs?

0 Answers  


Why everything in python is an object?

0 Answers  


How does python input work?

0 Answers  


Which methods of python are used to determine the type of instance and inheritance?

0 Answers  


Categories