arcgis python 表属性转html

import arcpy
import sys
import string
import os

tablePath = arcpy.GetParameterAsText(0)
filePath = arcpy.GetParameterAsText(1)

outfile = open(filePath, "w")
fields = arcpy.ListFields(tablePath)

fieldNames = []
for field in fields:
    if (field.type <> "Geometry" and field.type <> "BLOB"):
        fieldNames.append(field.name)
outfile.write("<table border=""1"">\n")
outfile.write("<tr>\n")

for fieldName in fieldNames:
    outfile.write("<th>" + fieldName + "</th>\n")
outfile.write("</tr>\n")

for row in arcpy.da.SearchCursor(tablePath, fieldNames):
    outfile.write("<tr>\n")
    for value in row:
        outfile.write(u"<td>" + str(value) + "</td>\n")
    outfile.write("</tr>\n")
outfile.write("</table>\n")

outfile.flush()
outfile.close()

 

上一篇:python获取Ip归属信息


下一篇:Python第五次作业——檀健勇