【发布时间】:2011-08-10 19:17:07
【问题描述】:
这段代码有什么问题?我想在文件夹中找到指定的文件。感谢您的帮助。
import os, fnmatch
def find(root, mask): //Error
files_list = os.listdir(os.path.abspath(root))
for filename in fnmatch.filter(files_list, mask):
yield filename
def test():
res = find ('D:\\Sample\\', 'hallo.txt')
test()
错误:
Error: Traceback (most recent call last): def find(root, mask): NoneType
【问题讨论】:
-
os.dir应该是什么? -
那么您是否收到任何错误,或者您的代码有什么问题?
-
@sth: 对不起,我没有写错误代码:-)
-
实际的错误信息仍然缺失。