for path in [dataset_train_path, dataset_val_path, dataset_test_path]: logging.info('path {}'.format(path)) path1, dirs1, files1 = os.walk(path).next() 报错:AttributeError: 'generator' object has no attribute 'next' 请帮我修改代码
时间: 2024-02-12 18:08:23 浏览: 140
delphi_dataset.zip_connect_dataset_dataset delphi_delphi dataset
Sure! To fix this error, you need to modify the line `path1, dirs1, files1 = os.walk(path).next()` to `path1, dirs1, files1 = next(os.walk(path))`.
Here's the modified code:
```
for path in [dataset_train_path, dataset_val_path, dataset_test_path]:
logging.info('path {}'.format(path))
path1, dirs1, files1 = next(os.walk(path))
```
This should resolve the `AttributeError` you were encountering. The `next()` function is used to get the next item from an iterator or generator in Python 3.x.
阅读全文