About 1,840,000 results
Open links in new tab
  1. Convert bytes to a string in Python 3 - Stack Overflow

    Mar 3, 2009 · 430 Decode the byte string and turn it in to a character (Unicode) string. Python 3:

  2. 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 …

  3. Python 2,3 Convert Integer to "bytes" Cleanly - Stack Overflow

    In Python 2 str(n) already produces bytes; the encode will do a double conversion as this string is implicitly converted to Unicode and back again to bytes. It's unnecessary work, but it's …

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

    Dec 23, 2012 · 5 This is a Python 101 type question, It's a simple question but one where the answer is not so simple. In python3, a "bytes" object represents a sequence of bytes, a "string" …

  5. How do I manipulate bits in Python? - Stack Overflow

    Aug 31, 2024 · In C I could, for example, zero out bit #10 in a 32-bit unsigned value like so: unsigned long value = 0xdeadbeef; value &= ~ (1<<10); How do I do that in Python?

  6. What is a "bytestring" (the `bytes` data type) in Python?

    Apr 3, 2014 · 10 As the name implies, a Python 2/3 bytes (or simply a str in Python 2.7) is a string of bytes. And, as others have pointed out, it is immutable.

  7. Python: How do I extract specific bits from a byte?

    I have a message which reads as 14 09 00 79 3d 00 23 27. I can extract each byte from this message by calling message[4], which will give me 3d for example. How do I extract the …

  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. How to convert hexadecimal string to bytes in Python?

    I have a long Hex string that represents a series of values of different types. I need to convert this Hex String into bytes or bytearray so that I can extract each value from the raw data. How can...

  10. python - How do I 'declare' an empty bytes variable? - Stack …

    Jan 21, 2022 · 47 How do I initialize ('declare') an empty bytes variable in Python 3? I am trying to receive chunks of bytes, and later change that to a utf-8 string. However, I'm not sure how to …