28
Come posso ottenere questo pezzo per seguire i collegamenti simbolici in Python 2.6?Python os.walk + seguire symlink
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
Grazie, 'os.walk (path, followlinks = True):' ha fatto il trucco, sebbene la documentazione di Python non fosse abbastanza chiara su questo: http://docs.python.org/library/os.path.html# os.path.walk –
@Frank: ovviamente non era chiaro; stai guardando la documentazione di 'os.path.walk', che è una funzione separata (vecchia e deprecata). Dovresti dare un'occhiata alla documentazione ['os.walk'] (http://docs.python.org/library/os.html#os.walk). – tzot