how can I export object position info from blender to text file?
This will write the location x,y and z values of the active object(bpy.context.object) at every frame starting from the start frame and finishing with the end frame set in the render settings under Dimensions section, Frame Range. You can change that by changing the for loop's condition. You can format the output as you need as well, just keep in mind you need to convert values you wish to output to strings.

import bpy

file = open("C:\\SomeDirectoryBlenderHasPermissionToAccess\\SomeFile.txt", 'w')
scene = bpy.context.scene
loc = bpy.context.object.location
for frames in range(scene.frame_start, scene.frame_end+1):
    scene.frame_set(frames)
    file.write('Loacton at frame '+str(frames)+':('
    +str(loc.x)+', '+str(loc.y)+', '+str(loc.z)+')\n')
file.close()


If you needed to run it for all objects in the scene you would need a loop within a loop:

...

for every_object in bpy.context.scene.objects:
    for every_frame in range(scene.frame_start, scene.frame_end+1):
        scene.frame_set(every_frame)
        loc = every_object.location
        file.write('Loacton at frame '+str(every_frame)+':('
        +str(loc.x)+', '+str(loc.y)+', '+str(loc.z)+')\n')

...


You can find more info on working with strings here. www.w3schools.com is a wonderful resource in general when learning Python. 

Blender Python documentation is usefull as well especially the search function there.

One more extremely useful place to learn is Blender itself. There are some very useful examples that come with Blender here: 


Also auto complete function(ctrl+space) is extremely useful in the Python Console: