Questions tagged «dictionary»

1
用Python修改属性表的最快方法?
不久前,我编写了一个快速的Python函数,用于将属性表转换为python字典,其中的键来自用户指定的唯一ID字段(通常是OID字段)。另外,默认情况下,所有字段都复制到字典中,但是我包含了一个参数,只允许指定一个子集。 def make_attribute_dict(fc, key_field, attr_list=['*']): dict = {} fc_field_objects = arcpy.ListFields(fc) fc_fields = [field.name for field in fc_field_objects if field.type != 'Geometry'] if attr_list == ['*']: valid_fields = fc_fields else: valid_fields = [field for field in attr_list if field in fc_fields] if key_field not in valid_fields: cursor_fields = valid_fields + …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.