工作空间

24 篇文章 0 订阅
23 篇文章 0 订阅
'''
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']
>>> 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值