Skip to main content
2 of 2
added 68 characters in body
Taras
  • 34k
  • 4
  • 73
  • 148

To get field names with fields() method or other field properties (length, type, comment, ...) you can use:

field_names = [field.name() for field in layer.fields()]
# ['id', 'attr1', 'attr2', 'attr3']

If you just need names, it's sufficient to use:

field_names = layer.fields().names()
# ['id', 'attr1', 'attr2', 'attr3']
Kadir Şahbaz
  • 78k
  • 57
  • 257
  • 404