You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

join_files.py 692 B

123456789101112131415161718192021
  1. import argparse
  2. def merge_files(file1_path: str, file2_path: str) -> str:
  3. # Open files in read mode
  4. with open(file1_path, 'r') as file1, open(file2_path, 'r') as file2:
  5. content1 = file1.read()
  6. content2 = file2.read()
  7. merged_content = content1 + "\n" + content2
  8. return merged_content
  9. if __name__ == "__main__":
  10. parser = argparse.ArgumentParser(description="Merge and print content from two text files.")
  11. parser.add_argument("file1", help="Path to the first text file.")
  12. parser.add_argument("file2", help="Path to the second text file.")
  13. args = parser.parse_args()
  14. output = merge_files(args.file1, args.file2)
  15. print(output)