我最终需要显示列表中所有以.shp结尾的项目。所以我需要能够分别索引每个列表项。有什么建议吗?你知道吗
到目前为止,我的情况是:
folderPath = r'K:\geog 173\LabData'
import os
import arcpy
arcpy.env.workspace = (folderPath)
arcpy.env.overwriteOutput = True
fileList = os.listdir(folderPath)
print fileList
"""Section 2: Identify and Print the number
and names of all shapefiles in the file list:"""
numberShp = 0
shpList= list()
for fileName in fileList:
print fileName
fileType = fileName[-4:]
print fileType
if fileType == '.shp':
numberShp +=1
shpList.append(fileName)
print shpList
print numberShp
请指定所需的输出格式。那会使工作变得容易。。。你知道吗
一个可能的答案是
使用list comprehensions和^{} 可以很容易地做到这一点:
相关问题 更多 >
编程相关推荐