How to iterate through all vertices of an object that contains multiple meshes?
A mesh may consist of loose parts the following script will export all vertices and faces. The length is determined by pythons len() you would need to change the print statements to writing into a file.

Uncomment the dump method # dump(obj.data) to find out more on available properties you're interested in. 

If you need also to get the edges of the mesh you could have a look at Python script to determine XYZ of tip of cone. 

import bpy

def dump(obj, level=0):
   for attr in dir(obj):
       if hasattr( obj, "attr" ):
           print( "obj.%s = %s" % (attr, getattr(obj, attr)))
       else:
           print( attr )


#obj = bpy.data.objects["Cube"]  # particular object by name
obj = bpy.context.scene.objects.active # active object

# dump(obj.data)
mesh = obj.data
print("# of vertices=%d" % len(mesh.vertices))
for vert in mesh.vertices:
    print( 'v %f %f %f\n' % (vert.co.x, vert.co.y, vert.co.z) )

print("# of faces=%d" % len(mesh.polygons))

for face in mesh.polygons:
    print('face')
    #dump(face)
    for vert in face.vertices:
        print(vert)


Output format:

# of vertices=8
v 1.000000 1.000000 -1.000000
v 1.000000 -1.000000 -1.000000
v -1.000000 -1.000000 -1.000000
v -1.000000 1.000000 -1.000000
v 1.000000 0.999999 1.000000
v 0.999999 -1.000001 1.000000
v -1.000000 -1.000000 1.000000
v -1.000000 1.000000 1.000000
# of faces=6
face
0
1
2
3
face
4
7
6
5
face
0
4
5
1
face
1
5
6
2
face
2
6
7
3
face
4
0
3
7