About 278,000 results
Open links in new tab
  1. 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 …

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

    Mar 3, 2009 · Here, the function will take the binary and decode it (converts binary data to characters using the Python predefined character set and the ignore argument ignores all non …

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

    Jun 3, 2011 · 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 …

  4. How to convert string to byte array in Python - Stack Overflow

    91 Say that I have a 4 character string, and I want to convert this string into a byte array where each character in the string is translated into its hex equivalent. e.g.

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

    Jul 14, 2020 · Note that the concatenated result takes on the type of the first argument, so a+b produces a bytes object and b+a produces a bytearray. Converting bytes and bytearray …

  6. string - 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 …

  7. How to convert between bytes and strings in Python 3?

    Dec 23, 2012 · Python uses "repr" as a fallback conversion to string. repr attempts to produce python code that will recreate the object. In the case of a bytes object this means among other …

  8. How do I convert a Python 3 byte-string variable into a regular …

    bytes_string=part.get_payload(decode=False) The payload comes in as a byte string, as my variable name suggests. I am trying to use the recommended Python 3 approach to turn this …

  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 …

  10. python - Print a string as hexadecimal bytes - Stack Overflow

    Mar 19, 2019 · If the idea is to return only 2-digit hex values, then this question implies the use of byte strings (i.e. Python 2 str or Python 3 bytestring), as there is no unequivocal transformation …