Guest User

Untitled

a guest
May 22nd, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. >>> s = "234" # "2" is a double-byte integer
  2. >>> if u"2" in s:
  3. print "y"
  4.  
  5. >>> if u"2" in s:
  6. print "y"
  7.  
  8. y
  9. >>> print s[0]
  10.  
  11. >>> print s[:2]
  12. >>> print s[:3]
  13. 23
  14.  
  15. text = incoming_bytes.decode("shift_jis")
  16. # ... do stuff ...
  17. outgoing_bytes = text.encode("shift_jis")
  18.  
  19. >>> import re
  20. >>> s = u"234"
  21. >>> digit = re.compile(r"d", re.U)
  22. >>> for d in re.findall(digit, s):
  23. ... print d,
  24. ...
  25. 2 3 4
  26. >>> wdigit = re.compile(u"[0-9]+")
  27. >>> for wd in re.findall(wdigit, s):
  28. ... print wd,
  29. ...
  30.  
  31. ord("2")
  32.  
  33. 65298
  34.  
  35. def convert_two_byte_numbers(character: str):
  36. if ord(character) in range(65296, 65306):
  37. return chr(ord(character) - 65248)
  38. else:
  39. return character
Add Comment
Please, Sign In to add comment