0
我不断收到错误name 'copyDir is not defined
,但它被定义为我的代码中的全局变量。哪里不对?我在这里回顾了其他一些类似的帖子,但仍然无法理解这个问题。这里是我的代码的开头部分:变量未定义,但它被定义为全局变量,python
import arcpy, os, shutil, re
mapIndex = r'C:\Temp\temp.gdb\MapSets_All'
copydDir = r'D:\MapSheetImages\All_Images'
fields = ['FileSpecDir','is_name']
for row in arcpy.da.SearchCursor(mapIndex,fields):
arcpy.env.workspace = row[0]
rstrList = arcpy.ListRasters()
for dir, folders, files in os.walk(row[0]):
try:
if 'CCS27z2e' in folders:
for r in rstrList:
if row[1] in r:
rOrigPath = os.path.join(row[0],r)
rNewPath = os.path.join(copyDir,r)
if not os.path.isfile(rNewPath):
arcpy.AddMessage('now copying '+r)
shutil.copyfile(rOrigPath,rNewPath)
except Exception as e:
print e
arcpy.AddMessage(e)
你的变量是'copydDir',不'copyDir'。错字 - 'copyDir'没有定义。 –
该代码是非常长的除了声明在最后,所以我没有发布它的一切,我会添加该部分它 – KLD
@AndrewDunai哦哇我看不到那些谢谢! – KLD