How to get the caption of a text object in Python?

I've got a Blender file with a lot of text objects and I want to do some scripting modifications on specific text with specific caption.

Is it possible to get the caption of a text curve in Blender?

For example, in the image below the caption that I want to find in Python is: 'This is a test'

• Text mesh? If it is a text curve you can get it's content via text_curve.body. You can get the text curve either from text_curve=bpy.data.curves[text_curve_name] or from an object using it text_curve=obj.data. – pink vertex Feb 3 '14 at 15:26
• Mmmh yep I've used the wrong term. Of course I use a text curve :S – lucblender Feb 3 '14 at 15:30

Yes, you can access the text via the body attribute,

Example:

# assume active object
obj = context.object
curve_text = obj.data

print(curve_text.body)

# set a new string
curve_text.body = "This is a NEW test :)"