About 50 results
Open links in new tab
  1. Python 3: Demystifying encode and decode methods

    Nov 20, 2012 · Let's say I have a string in Python: >>> s = 'python' >>> len(s) 6 Now I encode this string like this: >>> b = s.encode('utf-8') >>> b16 = s.encode('utf-16') >>> b32 = s.encode('utf-32') What I …

  2. python - What is the difference between encode/decode? - Stack …

    Jan 15, 2009 · The decode method of unicode strings really doesn't have any applications at all (unless you have some non-text data in a unicode string for some reason -- see below). It is mainly there for …

  3. Usage of unicode () and encode () functions in Python

    Apr 24, 2012 · Python byte strings (str type) have an encoding, Unicode does not. You can convert a Unicode string to a Python byte string using uni.encode(encoding), and you can convert a byte string …

  4. Python 3 - Encode/Decode vs Bytes/Str - Stack Overflow

    Encode () returns an 8-bit string in both cases. It's called "str" in Python 2 and "bytes" in Python 3, but both are 8-bit strings.

  5. How to urlencode a querystring in Python? - Stack Overflow

    Oct 22, 2015 · 5 For use in scripts/programs which need to support both python 2 and 3, the six module provides quote and urlencode functions:

  6. python - Why do I need 'b' to encode a string with Base64 ... - Stack ...

    That is what is happening when you take a string and call the .encode() method on it: Python is interpreting the string in utf-8 (the default encoding) and providing you the array of bytes that it …

  7. How to encode text to base64 in python - Stack Overflow

    In Python, bytes represents a sequence of bits and UTF-8 specifies the character encoding to use. The base64.b64encode function encodes bytes object into Base64 format.

  8. python - string encoding and decoding? - Stack Overflow

    Encoding is an operation that converts unicode to a byte string so Python helpfully attempts to convert your byte string to unicode first and, since you didn't give it an ascii string the default ascii decoder fails:

  9. Decoding UTF-8 strings in Python - Stack Overflow

    Feb 15, 2018 · I'm writing a web crawler in python, and it involves taking headlines from websites. One of the headlines should've read : And the Hip's coming, too But instead it said: And the Hip’s …

  10. Get a list of all the encodings Python can encode to

    Nov 13, 2009 · I am writing a script that will try encoding bytes into many different encodings in Python 2.6. Is there some way to get a list of available encodings that I can iterate over? The reason I'm tryin...