Guest User

Untitled

a guest
Oct 18th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. song = sys.argv[1]
  2. w = open(song)
  3. for line in sorted(w, key = int(len(line)))
  4. print line
  5.  
  6. song = sys.argv[1]
  7. w = open(song)
  8. for line in sorted(w, key=len)
  9. print line
  10.  
  11. song = sys.argv[1]
  12. w = open(song)
  13. for line in sorted(w, key=lambda x: len(x.split()))
  14. print line
  15.  
  16. lines = [line.rstrip().split() for line in file]
  17.  
  18. lines = [sorted(line.rstrip().split(), key=len) for line in file]
  19.  
  20. lines = sorted((sorted(line.rstrip().split(), key=len) for line in file), key=len)
  21.  
  22. for line in lines:
  23. print ' '.join(line)
  24.  
  25. sentences.sort(key=word_count)
  26.  
  27. words = get_words(sentence)
  28. words.sort(key=char_count)
  29.  
  30. #!/usr/bin/env python
  31. import io
  32. import sys
  33.  
  34. with io.open(sys.argv[1]) as file:
  35. sentences = file.read().splitlines() # NOTE: line ends are not included
  36. result = sorted([sorted(get_words(s), key=char_count)
  37. for s in sentences], key=word_count)
  38.  
  39. for words in result: # for each sentence
  40. print(' '.join(words))
  41.  
  42. get_words = unicode.split # split on arbitrary whitespace
  43. word_count = len # number of items in the list of words
  44. char_count = len # unicode word length
  45.  
  46. import re
  47.  
  48. words = re.findall(r'w+', sentence, flags=re.UNICODE)
  49.  
  50. >>> len(u"ะตฬˆ")
  51. 2
  52. >>> u"ะตฬˆ"
  53. u'u0435u0308'
  54.  
  55. >>> print(u'U0001f602')
  56. ๐Ÿ˜‚
  57. >>> len(_)
  58. 1
Add Comment
Please, Sign In to add comment