python使用os.walk进行遍历出现编码错误

本意是想用sklearn进行tf-idf统计的,需要对路径下的文件夹和文件进行遍历,现在有代码部分为

 path = 'D:\Python27'
 for subdir, dirs, files in os.walk(path):
    for file in files:
        file_path = subdir + os.path.sep + file

在没有修改编码方式程序运行出错,UnicodeDecodeError: 'utf8' codec can't decode byte 0xc6 in position 5266: invalid continuation byte
我试着添加了import sys reload(sys) sys.setdefaultencoding('utf-8') 这样程序倒是没错了,可是输出就是为空,有谁知道问题出在哪了?
还需要贴哪部分代码请说,感激不尽

文件路径中是否有中文或其他字符,需要编码处理一下