Error "Invalid MXD filename"
#-*- coding:utf-8 -*-
import arcpy.mapping as mapping
mxd = mapping.MapDocument("D:/2022项目/test.mxd")
frames = mapping.ListDataFrames(mxd)
print type(frames)
运行时报错如下:
assert (os.path.isfile(mxd) or (mxd.lower() == "current")), gp.getIDMessage(89004, "Invalid MXD filename")
AssertionError:
"Invalid MXD filename" 无效的MXD文件名称
原因:路径中有中文,无法正确识别路径
解决方法:在中文路径加u
,即可解决
mxd = mapping.MapDocument(u"D:/2022项目/test.mxd")