“String bajtowy Python” Kod odpowiedzi

String bajtowy Python

#A byte string can be decoded back into a character string, 
#if you know the encoding that was used to encode it.
b'I am a string'.decode('ASCII')
b'I am a string'.decode('utf-8')
Quaint Quoll

Bajty Pythona

>>> (1024).to_bytes(2, byteorder='big')
b'\x04\x00'
>>> (1024).to_bytes(10, byteorder='big')
b'\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00'
>>> (-1024).to_bytes(10, byteorder='big', signed=True)
b'\xff\xff\xff\xff\xff\xff\xff\xff\xfc\x00'
>>> x = 1000
>>> x.to_bytes((x.bit_length() + 7) // 8, byteorder='little')
b'\xe8\x03'
Mid-ager

Odpowiedzi podobne do “String bajtowy Python”

Pytania podobne do “String bajtowy Python”

Więcej pokrewnych odpowiedzi na “String bajtowy Python” w Python

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu