About 50 results
Open links in new tab
  1. What is a "bytestring" (the `bytes` data type) in Python?

    Apr 3, 2014 · 69 What exactly is a "bytestring" in Python? What is the bytes type, and how does it work internally? My understanding is that there are normal "ASCII strings", which store a sequence of …

  2. Convert bytes to a string in Python 3 - Stack Overflow

    Mar 3, 2009 · For your specific case of "run a shell command and get its output as text instead of bytes", on Python 3.7, you should use subprocess.run and pass in text=True (as well as …

  3. python 3.x - python3: bytes vs bytearray, and converting to and from ...

    Jul 14, 2020 · I'd like to understand about python3's bytes and bytearray classes. I've seen documentation on them, but not a comprehensive description of their differences and how they …

  4. What is Python's bytes type actually used for? - Stack Overflow

    Oct 9, 2019 · In short, the bytes type is a sequence of bytes that have been encoded and are ready to be stored in memory/disk. There are many types of encodings (utf-8, utf-16, windows-1255), which …

  5. Byte Array in Python - Stack Overflow

    Jul 11, 2015 · In Python 3, we use the bytes object, also known as str in Python 2.

  6. python - What is the difference between a string and a byte string ...

    Sep 3, 2022 · Assuming Python 3 (in Python 2, this difference is a little less well-defined) - a string is a sequence of characters, ie unicode codepoints; these are an abstract concept, and can't be directly …

  7. How to convert string to bytes in Python 3 - Stack Overflow

    Just a cautionary note from Python in a Nutshell about bytes: Avoid using the bytes type as a function with an integer argument. In v2 this returns the integer converted to a (byte)string because bytes is …

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

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

  9. "TypeError: a bytes-like object is required, not 'str'" when handling ...

    Python 2 does indeed have a type for bytes, it's just confusingly called str while the type for text strings is called unicode. In Python 3 they changed the meaning of str so that it was the same as the old …

  10. Python bytes concatenation - Stack Overflow

    A similar issue happens with the bytes constructor. If you pass a single integer in as the argument (rather than an iterable), you get a bytes instance that consists of that many null bytes ("\x00"). This …