You can use field_names = [field.name() for field in layer.fields()]
to get field names or other field properties (length
, type
, comment
, ...).
If you just need names, it's sufficient to use field_names = layer.fields().names()
You can use field_names = [field.name() for field in layer.fields()]
to get field names or other field properties (length
, type
, comment
, ...).
If you just need names, it's sufficient to use field_names = layer.fields().names()