英文:
Why function len() in arcpy mismatch with in fact
问题
I would like to know I use the function len()
in Arcpy and why the values that return does not match the fact.
from the function, len returns 12 but in fact list fields have 21. Please see my code
big = arcpy.ListFields('ลพบุรี_PSU_Select')
boss = len(big)
print(boss)
我想知道为什么我在Arcpy中使用len()
函数时,返回的值与实际情况不符。
从函数中,len
返回12,但实际上字段列表有21个。请查看我的代码
I would like the len
function to return the correct value.
英文:
I would like to know I use the function len()
in Arcpy and why the values that return does not match the fact.
from the function, len returns 12 but in fact list fields have 21. Please see my code
big=arcpy.ListFields('ลพบุรี_PSU_Select')
boss=len(big)
print(boss)
I would like to len function return follow true
答案1
得分: 2
The caption "1 of 21 selected" refers to the number of features (rows). There are 21 features in the layer, and one of them is selected.
In contrast, the ListFields
function is meant to return all the fields (columns) of the layer. This layer has 12 fields (OBJECTID, SHAPE, PSUNUM, ...).
英文:
The caption "1 of 21 selected" refers to the number of features (rows). There are 21 features in layer, and one of them is selected.
In contrast, the ListFields
function is meant to return all the fields (columns) of the layer. This layer has 12 fields (OBJECTID, SHAPE, PSUNUM, ...).
答案2
得分: 0
你可以使用以下方法来获取要素行数:
rows_amount = int(arcpy.management.GetCount('ลพบุรี_PSU_Select').getOutput(0))
ListFields
函数返回指定要素类的字段列表,通常包含 12 个字段。
英文:
If you want to get the amount of the features\rows you can use the GetCount method as follows:
rows_amount = int(arcpy.management.GetCount('ลพบุรี_PSU_Select').getOutput(0))
The ListFields
function returns a list of the fields for a specified feature class, which is likely to have 12 fields.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论