import arcpy
infc = r"C:\Users\123\Desktop\文件\test.shp"
print infc

desc = arcpy.Describe(infc)

print desc
shapefieldname = desc.ShapeFieldName
print shapefieldname

rows = arcpy.SearchCursor(infc)
print rows
for row in rows:

appear a error:
Traceback (most recent call last):
  File "C:/Users/123/Desktop/123.py", line 10, in <module>
    shapefieldname = desc.ShapeFieldName
AttributeError: DescribeData: \u65b9\u6cd5 ShapeFieldName \u4e0d\u5b58\u5728
  • try shapeFieldName instead of ShapeFieldName – radouxju Aug 31 '17 at 7:55
  • 3
    Welcome to GIS.SE! Can you please edit your question and describe what you're trying to achieve and give it a more specific title? – karpfen Aug 31 '17 at 8:11
  • ? I am a rookie,but I’care it next time – jiahui liu Aug 31 '17 at 8:20
  • 2
    Why only next time? You can edit your question... – pLumo Aug 31 '17 at 8:31
  • 1
    This Question is in the "Wall of code" style, not actually containing a question. This will attract downvotes, as will the "I'll do it right next time" attitude – Vince Aug 31 '17 at 10:25

You cant use the describe function to identify field names within a dataset. You have to use the ListFields function to do this.

If you need to know the field names, use the following:

fields = arcpy.ListFields(infc)
for fieldnames in fields:
    print fieldnames

Using list comprehension, we can convert the above code into one line:

fields = [field.name for field in arcpy.ListFields(infc)]

See the Describe function help for more information on what properties you can access.

Not the answer you're looking for? Browse other questions tagged or ask your own question.