如何让这段代码在 Python 2.6 中跟随符号链接?
def load_recursive(self, path):
for subdir, dirs, files in os.walk(path):
for file in files:
if file.endswith('.xml'):
file_path = os.path.join(subdir, file)
try:
do_stuff(file_path)
except:
continue
os.walk(path, followlinks=True)
解决了问题,虽然 Python 文档写得不太清楚:http://docs.python.org/library/os.path.html#os.path.walk。 - fmalinaos.path.walk
的文档。你应该查看os.walk
的文档。 - tzot