这个代码片段怎么可能。。。你知道吗
def subInPath(origPath, subPath):
origSplit = split(origPath, '/')
subSplit = split(subPath, '/')
subRoot = subSplit[0]
origSplit.reverse()
print origSplit.index(subRoot)
rootIndex = origSplit.index(subRoot)
origSplit[:rootIndex+1] = []
origSplit.reverse()
newPath = join(origSplit, sep)
newPath += (sep + subPath)
if not exists(newPath):
raise Exception, "Path subbed in not found."
return newPath
使用参数("C:/Users/MyName/Desktop/second_stage/Kickle_Pack/GardenLand_D.xml", "Kickle_Pack/Animations/TileAnims_48x48.xml")
。。。你知道吗
在print语句处输出2
,但在它下面的语句处抛出一个ValueError
。我很困惑。你知道吗
在处理目录或路径时始终使用
os.path
模块。它拥有处理目录所需的所有方法,而且它还具有在多个操作系统中兼容的优势。你知道吗这只是更好的软件工程。你知道吗
相关问题 更多 >
编程相关推荐