Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2021
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. import os
  2. arr = os.listdir()
  3. print(arr)
  4.  
  5.  
  6. n = 3 #the number of line to be read and deleted
  7.  
  8. for i in range(len(arr)):
  9. print(i)
  10. print(arr[i])
  11. file = open(arr[i], 'r')
  12. file_name = str(arr[i]) + '0'
  13. print(file_name)
  14. file_new= open(file_name, 'a')
  15. Lines = file.readlines()
  16. count = 0
  17. for line in Lines:
  18. count = count+ 1
  19. if (count>3):
  20. file_new.write(line)
  21. file_new.close()
  22.  
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement