How to export Bone Weights?
The objects data property contains the data used to define the objects appearance. For a mesh object that includes vertices, edges and polygons.

While vertex groups are stored within an objects properties, each groups vertex indices are direct indices into the objects data.vertices[] list. These are all kept in sync internally by blender so you don't have to be concerned, unless the mesh gets edited while you are accessing the data.

If you start with bpy.context.selected_objects you can export objects of type MESH. Then look at an objects modifiers list to find a modifier with a type of ARMATURE and get the object property from that to get the relevant armature.