NameError: name 'glob' is not defined
时间: 2023-09-16 12:13:59 浏览: 679
This error occurs when you try to use the `glob` module in Python but it hasn't been imported or it has been imported incorrectly.
To fix this error, you need to import the `glob` module by adding the following line at the beginning of your code:
```
import glob
```
If you have already imported the `glob` module and you are still getting this error, make sure that you have spelled the module name correctly and that you have not accidentally overwritten the module name with a variable or function of the same name.
相关问题
file_paths = glob.glob(os.path.join(folder_path, file_extension)) NameError: name 'glob' is not defined
This error occurs because the module `glob` has not been imported.
You can fix this error by adding the following line at the beginning of your code:
```python
import glob
```
This will import the `glob` module and make its functions available for use in your code.
Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'glob' is not defined
这个错误是因为在你的代码中没有正确导入`glob`模块。在使用`glob`模块之前,你需要先导入它。
在你的代码开头添加以下导入语句:
```python
import glob
```
这将导入`glob`模块,并解决`NameError: name 'glob' is not defined`错误。然后,你可以继续使用`glob.glob()`函数来获取文件路径列表。
阅读全文