- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the difference between encode/decode in Python?
To represent a unicode string as a string of bytes is known as encoding. To convert a string of bytes to a unicode string is known as decoding. You typically encode a unicode string whenever you need to use it for IO, for instance transfer it over the network, or save it to a disk file. You typically decode a string of bytes whenever you receive string data from the network or from a disk file.
To encode a string using a given encoding you can do the following:
To decode astring(using the same encoding used to encode it), you need to call decode(encoding). For example:
This string in utf8 encoding is equivalent to u'æøå'
- Encode and decode uuencode files using Python
- Encode and Decode Strings in C++
- Encode and decode binhex4 files using Python (binhex)
- Encode and decode XDR data using Python xdrlib
- Arduino – base64 encode and decode
- Encode and decode MIME quoted-printable data using Python
- How to Encode and Decode JSON and Lua Programming?
- What is the difference between = and == operators in Python?
- What is the difference between attributes and properties in python?
- What is the difference between os.open and os.fdopen in python?
- What is the difference between dict.items() and dict.iteritems() in Python?
- What is the difference between __str__ and __repr__ in Python?
- What is the difference between Python functions datetime.now() and datetime.today()?