【发布时间】:2017-10-01 20:00:48
【问题描述】:
我必须检查该文件是否存在,如果存在,则必须返回它的路径,主要问题是 os.path.isdir 仅返回 True 或 False 取决于存在,所以看起来不适合。有什么提示吗?我心中的当前架构是:
def get_config_path():
if exists(path1):
return path1
if exists(path2):
return path2
【问题讨论】:
-
那么
path1和path2来自哪里?如果它们没有在函数中定义,你应该使用参数。
标签: python file-handling