Guest User

Untitled

a guest
Mar 19th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. my_string = b'The string'
  2.  
  3. print('שלום עולם')
  4.  
  5. NaN = struct.unpack('>d', b'xffxf8x00x00x00x00x00x00')[0]
  6.  
  7. >>> 'uFEFF'.encode('UTF-8')
  8. b'xefxbbxbf'
  9.  
  10. >>> b'xE2x82xAC'.decode('UTF-8')
  11. '€'
  12.  
  13. >>> b'xEFxBBxBF' + 'Text with a UTF-8 BOM'
  14. Traceback (most recent call last):
  15. File "<stdin>", line 1, in <module>
  16. TypeError: can't concat bytes to str
  17.  
  18. >>> b'A' == b'x41'
  19. True
  20.  
  21. >>> 'A' == b'A'
  22. False
  23.  
  24. >>> f=open("new", "wb")
  25. >>> f.write("Hello Python!")
  26. Traceback (most recent call last):
  27. File "<stdin>", line 1, in <module>
  28. TypeError: 'str' does not support the buffer interface
  29.  
  30. >>> len('Öl') # German word for 'oil' with 2 characters
  31. 2
  32. >>> 'Öl'.encode('UTF-8') # convert str to bytes
  33. b'xc3x96l'
  34. >>> len('Öl'.encode('UTF-8')) # 3 bytes encode 2 characters !
  35. 3
Add Comment
Please, Sign In to add comment