Contact: aviboots(AT)netvision.net.il
39,971 questions
51,913 answers
573 users
b = bytes("python", "ascii") print(b) s = b.decode("ascii") print(s) ''' run: b'python' python '''
s = b"python".decode("utf-8") print(s) ''' run: python '''
bytes = b'\x61\x62' s = bytes.decode() print(s) ''' run: ab '''
bytes = b'\xF1\x62' s = bytes.decode('utf-8', 'ignore') print(s) ''' run: b '''
bytes = b'\xF1\x62' s = bytes.decode('utf-8', 'replace') print(s) ''' run: �b '''
bytes = b'\xF1\x62' s = bytes.decode('utf-8', 'backslashreplace') print(s) ''' run: \xf1b '''
bytes = b'\x61\x62\x63' s = "".join([chr(_) for _ in bytes]) print(s) ''' run: abc '''
bytes = b'\x61\x62\x63' s = "".join(map(chr, bytes)) print(s) ''' run: abc '''
by = [97, 98, 99, 100] s = "".join(map(chr, by)) print(s) ''' run: abcd '''
s = str(b'python', "utf-8") print(s) ''' run: python '''
by = bytes(b"python") s = by.decode("ascii") print(s) ''' run: python '''
s = b'\x49\x53\x55'.decode('utf-8') print(s) ''' run: ISU '''