>>> import sys ... ... reload(sys) ... ... sys.setdefaultencoding('utf-8') ... ... import arcpy ... ... import string ... ... try: ... ... workspace = 'C:\Users\Administrator\Desktop\\qwe' ... ... outdb = 'C:\Users\Administrator\Desktop\\lutian.mdb' ... ... arcpy.env.workspace = workspace ... ... files = arcpy.ListFiles('*.*db') ... ... arcpy.env.workspace = outdb ... ... fcs = arcpy.ListFeatureClasses() ... ... fcs = fcs + arcpy.ListTables() ... ... dss = arcpy.ListDatasets() ... ... for File in files: ... ... for fc in fcs: ... ... arcpy.Append_management(workspace + '\\' + File + '\\' + fc, outdb + '\\' + fc) ... ... for ds in dss: ... ... fcs1 = arcpy.ListFeatureClasses(feature_dataset = ds) ... ... for fc1 in fcs1: ... ... arcpy.Append_management(workspace + '\\' + File + '\\' + ds + '\\' + fc1, outdb + '\\' + ds + '\\' + fc1) ... ... except arcpy.ExecuteError: ... ... print arcpy.GetMessages() ... Parsing error IndentationError: expected an indented block (line 13),展示修改后的代码
时间: 2024-02-09 10:10:29 浏览: 142
这里是修改后的代码,你可以尝试运行看看。
```python
import sys
import arcpy
import string
reload(sys)
sys.setdefaultencoding('utf-8')
try:
workspace = 'C:\Users\Administrator\Desktop\\qwe'
outdb = 'C:\Users\Administrator\Desktop\\lutian.mdb'
arcpy.env.workspace = workspace
files = arcpy.ListFiles('*.*db')
arcpy.env.workspace = outdb
fcs = arcpy.ListFeatureClasses()
fcs = fcs + arcpy.ListTables()
dss = arcpy.ListDatasets()
for File in files:
for fc in fcs:
arcpy.Append_management(workspace + '\\' + File + '\\' + fc, outdb + '\\' + fc)
for ds in dss:
fcs1 = arcpy.ListFeatureClasses(feature_dataset = ds)
for fc1 in fcs1:
arcpy.Append_management(workspace + '\\' + File + '\\' + ds + '\\' + fc1, outdb + '\\' + ds + '\\' + fc1)
except arcpy.ExecuteError:
print arcpy.GetMessages()
```
修改后的代码中,缩进问题已经被修复,每个代码块都正确缩进。另外,由于你使用了Python 2.x版本,所以在代码中加入了`reload(sys)`和`sys.setdefaultencoding('utf-8')`,以确保正确处理中文字符集。
阅读全文