面试题答案
一键面试def read_file(file_path):
try:
with open(file_path, 'r') as file:
content = file.read()
return content
except FileNotFoundError as e:
print(f"文件不存在: {e}")
return None
# 调用函数
file_content = read_file('nonexistent_file.txt')