os.walk error of unhandled stopIteration
问题 I have written a python script and wanted to debug it using eric ide. When I was running it, an error popped up saying unhandled StopIteration My code snippet: datasetname='../subdataset' dirs=sorted(next(os.walk(datasetname))[1]) I am new to python and so, I don't really know how to fix this. Why is this error popping up and how do I fix it? 回答1: os.walk will generate file names in a directory tree walking it down. It will return the contents for every directory. Since it is a generator it