import os
# 检查文件是否存在
def check_file_exists(file_path):
"""
检查给定路径的文件是否存在。
参数:
file_path (str): 文件的完整路径。
返回:
bool: 如果文件存在返回True,否则返回False。
"""
return os.path.exists(file_path)
# 示例用法
file_path = 'example.txt'
if check_file_exists(file_path):
print(f"文件 '{file_path}' 存在。")
else:
print(f"文件 '{file_path}' 不存在。")
下一篇:python url paser
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站