代码如下:
#encoding=utf-8 print '中国' #查找目录中的第一个文件,指定类型 import os def search_file(filename, search_path, pathsep = os.pathsep): for path in search_path.split(pathsep): candidate=os.path.join(path,filename) if os.path.isfile(candidate): return os.path.abspath(candidate) return None print search_file(r'ft.ini', r'H:\football\GetFootballMatch\Release')
打印结果如下:
中国
H:\football\GetFootballMatch\Release\ft.ini