def SaveShpAsCSV(ShpFile,OutDir,OutputName): fields = arcpy.gp.listFields(ShpFile) fieldList2 = [] for field in fields: fieldList2.append(str(field.name)) try: arcpy.ExportXYv_stats(ShpFile,fieldList2,"COMMA",OutDir+"/"+OutputName+".csv","ADD_FIELD_NAMES") except: print arcpy.gp.GetMessages()
SaveShpCSV(),3个传入参数,输出的csv就可以用excel打开。。。