28
Làm thế nào để tôi nhận được phần này để theo dõi các liên kết tượng trưng trong python 2.6?Python os.walk + follow symlinks
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
Cảm ơn bạn, 'os.walk (đường dẫn, followlinks = True):' đã thực hiện thủ thuật, mặc dù tài liệu Python không rõ ràng về điều này: http://docs.python.org/library/os.path.html# os.path.walk –
@Frank: tất nhiên là không rõ ràng; bạn đang xem tài liệu cho 'os.path.walk' là một hàm riêng biệt (cũ hơn và không dùng nữa). Bạn nên xem tài liệu ['os.walk'] (http://docs.python.org/library/os.html#os.walk). – tzot