在我的while循环中的某个特定点,我跑步操作系统列表目录在一个三项索引上生成一个文件列表,我得到“Windows错误3-路径不存在”,尽管我以前在脚本中成功地调用了这个路径。你知道吗
我跑了一辆os.path.exists存在在它之后,它说,对于前两个循环,目录的计算结果为False,但在第三个循环中,它的计算结果为True。你知道吗
我试过用全球。全球它也只返回第三个循环中的文件。你知道吗
问题在于while循环中的“根据找到的快照数创建读取节点”注释。你知道吗
任何帮助必须阅读它作为真正的从一开始将不胜感激,谢谢!你知道吗
# Iterating using while loop, this gets every version folder for each shots' plates and stores to a "version" list
while shotIndex < shotAmountTotal:
nextShot = (shots[shotIndex])
shotIndex += 1
verSearchPath = shotSearchPath + '/' + nextShot + '/' + compFolder + '/' + platesFolder
foundVerList = os.listdir(verSearchPath)
verListCombined.append(foundVerList)
verListSorted = list(chain.from_iterable(verListCombined))
#this groups the like folder names, splits them at the underscore before the version number and then returns only the highest version number of each group
groupedShotFolders = groupby(verListSorted, key=lambda version: version.rsplit('_', 1)[0])
latestShotVer = [sorted(group, reverse=True)[0] for key, group in groupedShotFolders]
#creates Read nodes based on number of shots found
latestShotAmount = len(latestShotVer)
latestShotIndex = 0
while latestShotIndex < latestShotAmount:
latestShot = (latestShotVer[latestShotIndex])
frameListerPath = verSearchPath + '/' + latestShot + '/' + fileExtension + '/'
print os.path.exists(frameListerPath)
frameLister = os.listdir(verSearchPath + '/' + latestShot + '/' + fileExtension + '/')
我得到的终端输出是:
Result: False
E:/projects/MBR/shots/103/MRS_103_005_020/2d/plates/MRS_103_005_010_BG_001_v002/exr/
[]
False
E:/projects/MBR/shots/103/MRS_103_005_020/2d/plates/MRS_103_005_010_FG_001_v003/exr/
[]
True
E:/projects/MBR/shots/103/MRS_103_005_020/2d/plates/MRS_103_005_020_BG_001_v003/exr/
['E:/projects/MBR/shots/103/MRS_103_005_020/2d/plates/MRS_103_005_020_BG_001_v003/exr\\MRS_103_005_020_BG_001_v003.0999.exr', 'E:/projects/MBR/shots/103/MRS_103_005_020/2d/plates/MRS_103_005_020_BG_001_v003/exr\\MRS_103_005_020_BG_001_v003.1000.exr', 'E:/projects/MBR/shots/103/MRS_103_005_020/2d/plates/MRS_103_005_020_BG_001_v003/exr\\MRS_103_005_020_BG_001_v003.1001.exr', 'E:/projects/MBR/shots/103/MRS_103_005_020/2d/plates/MRS_103_005_020_BG_001_v003/exr\\MRS_103_005_020_BG_001_v003.1002.exr']
好吧,我要把这个归咎于用户错误。首先,我切换到“for”和“join”方法来清理一些东西。接下来,我发现前面代码中的“nextShot”变量没有正确迭代,所以它只输出迭代的最后一项,这就是为什么前两个路径的计算结果为False。我通过将“latestShot”变量放在适当的位置并删掉描述符来解决这个问题。你知道吗
以避免发生在操作系统列表目录“我把它分开,用前斜杠重新连接起来。你知道吗
谢谢你的想法和指导。你知道吗
相关问题 更多 >
编程相关推荐