Advertisement
Guest User

Untitled

a guest
Mar 29th, 2020
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. def my_mp4_playlist(file_path, new_song):
  2.  
  3. open_file = open(file_path, "r")
  4. text = open_file.read()
  5. list = text.split("\n")
  6. open_file.close()
  7. change_text = open(file_path, "w")
  8. length = len(list)
  9. count = 0
  10.  
  11. if length >= 3:
  12.  
  13. for letter in list[2]:
  14. if letter == ";":
  15. break
  16. count += 1
  17. list[2] = new_song + list[2][count::]
  18. string = "\n".join(list)
  19. change_text.write(string)
  20. change_text.close()
  21. print(string)
  22. else:
  23. i = length
  24. while i < 3:
  25. list.append("")
  26. i += 1
  27.  
  28. for letter in list[2]:
  29. if letter == ";":
  30. break
  31. count += 1
  32. list[2] = new_song + list[2][count::]
  33.  
  34. string = "\n".join(list)
  35. change_text.write(string)
  36. change_text.close()
  37. print(string)
  38.  
  39.  
  40. my_mp4_playlist(r"C:\New folder\a.txt", "gay")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement