import arcgisscripting
gp=arcgisscripting.create(9.3)
gp.workspace="D:/test"
try:
gp.MakeFeatureLayer("D:/test/sheng.shp", "sheng")
gp.SelectLayerByAttribute("sheng", "NEW_SELECTION", "zonecode=45000000")
gp.SelectLayerByLocation("sheng", "SHARE_A_LINE_SEGMENT_WITH", "sheng") #空间查询
#gp.CopyFeatures("sheng", "d:/test/bbb.shp")
result = gp.GetCount_management("sheng")
count = int(result.GetOutput(0))
print count
desc = gp.Describe("sheng")
fields = desc.Fields
rows = gp.SearchCursor("sheng")
row=rows.Next()
while row:#遍历记录
print row.zonecode
#for field in fields: #遍历字段
# print row.GetValue(field.Name)
print "*****************"
row=rows.Next()
print "ok"
except:
print gp.getMessages(2)