Guest User

Untitled

a guest
Nov 13th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. import sys
  2.  
  3. def get_lines(filepath):
  4. """ Reads the contents of filename
  5. and returns the - File handle
  6. - List of all lines of the file
  7. """
  8. FH = open(filepath, "r+")
  9. lines = FH.readlines()
  10. return FH, lines
  11.  
  12. def write_lines(new_filename, new_lines):
  13. """ Writes the lines into the a file whose
  14. filename is given as argument
  15. """
  16. FH = open("C:\\Users\\Ojha\\Documents\\Python exercises\\Python Scripts\\" + new_filename, "w")
  17. for line in new_lines:
  18. FH.write(line)
  19. FH.close()
Add Comment
Please, Sign In to add comment