
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Encode and Decode XDR Data Using Python xdrlib
Encoders and decoders for the External Data Representation (XDR). When we transport data between different external sources, this is the commonly used format that is used. It useful for creation and transfer of complex data structures. XDR provides a service associated with the OSI Presentation Layer.
In the below program we see how the data is getting packed and unpacked using the xdrlib module.
Example
import xdrlib p = xdrlib.Packer() print(type(p)) lst = [1,2,3] p.pack_list(lst, p.pack_int) print(p) u = xdrlib.Unpacker(p) print(type(u)) print(lst)
Running the above code gives us the following result −
Output
<xdrlib.Packer object at 0x000002272F3D6FD0> [1, 2, 3]
Advertisements