Files
Brancheneinstufung2/ARCHIVE_legacy_scripts/read_file_content.py

20 lines
640 B
Python

import argparse
def read_file_content(file_path):
"""Reads and prints the content of a specified file."""
try:
with open(file_path, 'r', encoding='utf-8') as f:
print(f.read())
except FileNotFoundError:
print(f"Error: File not found at '{file_path}'")
except Exception as e:
print(f"An error occurred: {e}")
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Read and display the content of a file.")
parser.add_argument("file_path", help="The path to the file you want to read.")
args = parser.parse_args()
read_file_content(args.file_path)