I found a code that prints all data that a shapefile has in the attribute table in the qgis console. But i wanted to have a code that just printed the data that i select in the shapefile. Can someone help me?
I'll leave here the code that prints all the data.
lyr = iface.activeLayer() features = lyr.getFeatures() featList =  selected_features = layer.selectedFeatures() for feat in features: featList.append(feat.attributes()) featList.sort() for f in featList: print f