工作空间

    xiaoxiao2024-12-25  55

    ''' import os wspath='E:\\bao2' v=os.walk(wspath) print(v) for i in v: print(i) import arcpy,os workspace='E:\\bao1' feature_classes=[] for dirpath,dirnames,filenames in arcpy.da.Walk(workspace,datatype='FeatureClass',type='Point'): for filename in filenames: feature_classes.append(os.path.join(dirpath,filename)) ''' import arcpy,os workspace='E:\\bao1' feature_classes=[] v=arcpy.da.Walk(workspace,topdown=True,datatype='FeatureClass',type='Point') for dirpath,dirnames,filenames in v: print('1: ',dirpath,dirnames,filenames) for i in dirnames: if i.split('.')[-1]=='gdb': dirnames.remove(i) for filename in filenames: feature_classes.append(os.path.join(dirpath,filename)) print('2: ',dirpath,dirnames,filenames) print(feature_classes)

    结果:

    <generator object walk at 0x0000000003064948> ('E:\\bao2', ['1', 'bao2.gdb'], ['1.txt', 'newdatabase.py', 'workspace.py']) ('E:\\bao2\\1', ['2'], ['2.txt']) ('E:\\bao2\\1\\2', ['3'], ['3.txt']) ('E:\\bao2\\1\\2\\3', [], ['4.txt']) ('E:\\bao2\\bao2.gdb', [], ['a00000001.gdbindexes', 'a00000001.gdbtable', 'a00000001.gdbtablx', 'a00000001.TablesByName.atx', 'a00000002.gdbtable', 'a00000002.gdbtablx', 'a00000003.gdbindexes', 'a00000003.gdbtable', 'a00000003.gdbtablx', 'a00000004.CatItemsByPhysicalName.atx', 'a00000004.CatItemsByType.atx', 'a00000004.FDO_UUID.atx', 'a00000004.gdbindexes', 'a00000004.gdbtable', 'a00000004.gdbtablx', 'a00000004.spx', 'a00000005.CatItemTypesByName.atx', 'a00000005.CatItemTypesByParentTypeID.atx', 'a00000005.CatItemTypesByUUID.atx', 'a00000005.gdbindexes', 'a00000005.gdbtable', 'a00000005.gdbtablx', 'a00000006.CatRelsByDestinationID.atx', 'a00000006.CatRelsByOriginID.atx', 'a00000006.CatRelsByType.atx', 'a00000006.FDO_UUID.atx', 'a00000006.gdbindexes', 'a00000006.gdbtable', 'a00000006.gdbtablx', 'a00000007.CatRelTypesByBackwardLabel.atx', 'a00000007.CatRelTypesByDestItemTypeID.atx', 'a00000007.CatRelTypesByForwardLabel.atx', 'a00000007.CatRelTypesByName.atx', 'a00000007.CatRelTypesByOriginItemTypeID.atx', 'a00000007.CatRelTypesByUUID.atx', 'a00000007.gdbindexes', 'a00000007.gdbtable', 'a00000007.gdbtablx', 'gdb', 'timestamps']) >>> ================================ RESTART ================================ >>> <generator object walk at 0x0000000003084948> E:\bao2 ['1', 'bao2.gdb'] ['1.txt', 'newdatabase.py', 'workspace.py'] E:\bao2\1 ['2'] ['2.txt'] E:\bao2\1\2 ['3'] ['3.txt'] E:\bao2\1\2\3 [] ['4.txt'] E:\bao2\bao2.gdb [] ['a00000001.gdbindexes', 'a00000001.gdbtable', 'a00000001.gdbtablx', 'a00000001.TablesByName.atx', 'a00000002.gdbtable', 'a00000002.gdbtablx', 'a00000003.gdbindexes', 'a00000003.gdbtable', 'a00000003.gdbtablx', 'a00000004.CatItemsByPhysicalName.atx', 'a00000004.CatItemsByType.atx', 'a00000004.FDO_UUID.atx', 'a00000004.gdbindexes', 'a00000004.gdbtable', 'a00000004.gdbtablx', 'a00000004.spx', 'a00000005.CatItemTypesByName.atx', 'a00000005.CatItemTypesByParentTypeID.atx', 'a00000005.CatItemTypesByUUID.atx', 'a00000005.gdbindexes', 'a00000005.gdbtable', 'a00000005.gdbtablx', 'a00000006.CatRelsByDestinationID.atx', 'a00000006.CatRelsByOriginID.atx', 'a00000006.CatRelsByType.atx', 'a00000006.FDO_UUID.atx', 'a00000006.gdbindexes', 'a00000006.gdbtable', 'a00000006.gdbtablx', 'a00000007.CatRelTypesByBackwardLabel.atx', 'a00000007.CatRelTypesByDestItemTypeID.atx', 'a00000007.CatRelTypesByForwardLabel.atx', 'a00000007.CatRelTypesByName.atx', 'a00000007.CatRelTypesByOriginItemTypeID.atx', 'a00000007.CatRelTypesByUUID.atx', 'a00000007.gdbindexes', 'a00000007.gdbtable', 'a00000007.gdbtablx', 'gdb', 'timestamps'] >>> ================================ RESTART ================================ >>> ('1: ', u'E:\\bao1', [u'bao1.gdb'], [u'henanligongdaxue.shp', u'kaida.shp']) ('2: ', u'E:\\bao1', [], [u'henanligongdaxue.shp', u'kaida.shp']) [u'E:\\bao1\\henanligongdaxue.shp', u'E:\\bao1\\kaida.shp'] >>>
    最新回复(0)