在MXD空间中从文件名中提取行政村名称(用于定义查询)

代码:

#encoding=gbk
#在python中正确,在arcgis中出错
import re,os,string
mz = '街道'
for root,dirs,files in os.walk(r'O:\arcgis_directory\MXD\RHYXT'):
	for afile in files:
		if afile[-4:].lower() == '.mxd':
				new_name = re.findall('.*街道(.*)村.*',afile)
			        for anew_name in new_name:
				        print anew_name.decode('gbk') + u'村'

转载自:https://blog.csdn.net/qq_35515661/article/details/80849249

You may also like...