import arcpy
mxd = arcpy.mapping.MapDocument("current") #获取当前打开的文档
layers = arcpy.mapping.ListLayers(mxd) #获取当前的图层组
#对图层进行循环处理
for layer in layers:
arcpy.AddField_management(layer,"name","TEXT","#",50) #添加名称为name的字段
fieldArrays=arcpy.ListFields(layer) #获取字段列表
arcpy.DeleteField_management(layer,fieldArrays[2].name) #删除原来排第二个不需要的字段
data = layer.name.split('_')[0] #获取需要的内容
arcpy.CalculateField_management(layer, "name", '\"'+ data + '\"', "VB", "") #对name字段赋值