Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- my_string = b'The string'
- print('שלום עולם')
- NaN = struct.unpack('>d', b'xffxf8x00x00x00x00x00x00')[0]
- >>> 'uFEFF'.encode('UTF-8')
- b'xefxbbxbf'
- >>> b'xE2x82xAC'.decode('UTF-8')
- '€'
- >>> b'xEFxBBxBF' + 'Text with a UTF-8 BOM'
- Traceback (most recent call last):
- File "<stdin>", line 1, in <module>
- TypeError: can't concat bytes to str
- >>> b'A' == b'x41'
- True
- >>> 'A' == b'A'
- False
- >>> f=open("new", "wb")
- >>> f.write("Hello Python!")
- Traceback (most recent call last):
- File "<stdin>", line 1, in <module>
- TypeError: 'str' does not support the buffer interface
- >>> len('Öl') # German word for 'oil' with 2 characters
- 2
- >>> 'Öl'.encode('UTF-8') # convert str to bytes
- b'xc3x96l'
- >>> len('Öl'.encode('UTF-8')) # 3 bytes encode 2 characters !
- 3
Add Comment
Please, Sign In to add comment