script1~20171217-161704.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. import random
  4. occurences = ["What are the demands","There are no demands","The demands","Impossible demands", "Impossible demand","We demand the impossible","Impossible to demand"]
  5. democracy = "democracy"
  6. democracy_majuscule = democracy.upper()
  7. print(democracy_majuscule)
  8. liste = list( democracy )
  9. random.shuffle( liste )
  10. democracy_shuffled = ''.join( liste )
  11. print(democracy_shuffled)
  12. # read stopwords from file & save them in a list
  13. # read from file
  14. with open("occupy.txt", "r") as source:
  15. # for each line
  16. txt = source.readline()
  17. print(txt)
  18. new_txt = txt.replace(democracy, democracy_shuffled)
  19. print(new_txt)
  20. # clean returns
  21. #line = line.strip()
  22. #print(line)
  23. #split sentences into words
  24. #words = line.split()
  25. #for each words ...
  26. #for word in words:
  27. #print("words:", words)
  28. #print(" ".join(words))
  29. #replace what are the demands
  30. sentence = occurences[0]
  31. print("sentence:", sentence)
  32. sentence.replace("What are the demands"," what are the demands ")
  33. print("sentence")
  34. #replace there are no demands
  35. sentence = occurences[1]
  36. sentence.replace("there are no demands","therearenodemands")
  37. print("sentence")
  38. #reverse order
  39. sentence = occurences[4,5,7]
  40. chaine = "impossible demands, impossible demand, impossible to demand"
  41. chaine = chaine [::-1]
  42. print(chaine)
  43. # passer en majuscule
  44. sentence = occurences[6]
  45. #sentence = sentence.upper()
  46. #print(sentence)
  47. # écrire la nouvelle liste comme chaîne de caractères dans un fichier texte
  48. #with open('export.txt', 'w') as f:
  49. #f.write(script1)