Python 找不到现有文件的无法解释的文件

Python 找不到现有文件的无法解释的文件,python,maya,Python,Maya,下面是这部分代码中出现的错误。虽然路径有效,但会发生运行时错误。发生了什么事,我怎样才能让它起作用 for root,dirs,files in os.walk(self.path): for f in files : if (f.split('.')[1] == "mb"): z = utils.executeInMainThreadWithResult(self.contains,(f.s

下面是这部分代码中出现的错误。虽然路径有效,但会发生运行时错误。发生了什么事,我怎样才能让它起作用

        for root,dirs,files in os.walk(self.path):
            for f in files :
                if (f.split('.')[1] == "mb"):
                z = utils.executeInMainThreadWithResult(self.contains,(f.split('.')[0]))
                    if not (isinstance(z,NoneType)):
                        cmds.symbolButton(self.arSubCategory + f.split('.')[0], image=(z[1].replace("\\","/")), width = 35,height = 70, c = "h.imp_file(" + "\"" + root.replace("\\","/")  + "/" + f + "\"" + ")")


def contains(self,imageName):
    print 'imageName : ',imageName,'\n'
    for root, dirs, files in os.walk(self.path+"images"):
        for g in files:
            x = re.search(imageName,g)
            if not (isinstance(x, NoneType)):
                print 'g ',root+"/"+g.replace("\\","/"),'\n'
                return (1,(root+"/"+g))
错误:

# z is (1, 'T:/Reference_Library/Reference_work/Char_models/Workfiles/images\\rboxdisk1\\female\\highpoly/granny01_highpoly.jpg')

Error: File not found: T:/Reference_Library/Reference_work/Char_models/Workfiles/images/rboxdisk1/female/highpoly/granny01_highpoly.jpg
Traceback (most recent call last):
File "<maya console>", line 115, in <module>
File "<maya console>", line 65, in showWindowanimLibrary
RuntimeError: File not found: T:/Reference_Library/Reference_work/Char_models/Workfiles/images/rboxdisk1/female/highpoly/granny01_highpoly.jpg
#z是(1,'T:/Reference_Library/Reference_work/Char_models/Workfiles/images\\rboxdisk1\\female\\highpoly/granny01_highpoly.jpg')
错误:未找到文件:T:/Reference\u Library/Reference\u work/Char\u models/Workfiles/images/rboxdisk1/female/highpoly/granny01\u highpoly.jpg
回溯(最近一次呼叫最后一次):
文件“”,第115行,在
ShowWindowAnim库中第65行的文件“”
运行时错误:未找到文件:T:/Reference\u Library/Reference\u work/Char\u models/Workfiles/images/rboxdisk1/female/highpoly/granny01\u highpoly.jpg

您对文件夹中的所有文件都有写入权限吗?

建议您使用
os.path
中的函数来操作路径。例如,
os.path.join
os.path.splitext