Blender Text Editor Change Text Cursor code example
Example: blender change text during animation
import bpy
scene = bpy.context.scene
obj = scene.objects['Text']
def recalculate_text(scene):
obj.data.body = 'Current frame: ' + str(scene.frame_current)
bpy.app.handlers.frame_change_pre.append(recalculate_text)