Text Game Properties in Blender (Python)
A text object gets it's own button to Add Text Game Property. This button produces the same effect as the normal Add Game Property with the type set to string and name set to 'Text'. This 'Text' property of the text object gives the ability to get and set the contents of the text object during game play.

The 'Text' property can be accessed the same as other game properties, by treating the object as a dictionary and the property name as the key.

In a python script used as a controller that would normally be with -

cont = bge.logic.getCurrentController()
own = cont.owner
txtVal = own['Text']
own['Text'] = 'NewString'
own['prop'] = 25
own['prop2'] = 'a big long string'


Other objects in the game can also be accessed -

sce = bge.logic.getCurrentScene()
sce.objects['otherObj']['Text'] = 'something'
sce.objects['missile']['prop3'] = 356


Properties changed during game play only exist for the duration of the game. Values set in the Game Logic Editor will be in effect at the start of a game, with the 'Text' property being set to the contents of the text object set in edit mode.

EDIT: response to your code example.

While your debugging your scripts you will want to watch the console output. It can contain hints as to why your scripts fails.

In python scripts formatting is important, the indentation defines separate parts of code. Not sure if any formatting got lost copying your code across but it appears you have a function and the following code might be meant to be part of that, if so that code isn't going to run unless you add a function call at the end of the script. For this small script you don't need any functions.

The all important last line, you are mixing strings and integers which you need to convert to work as you want. int(strValue) will give you a number you can calculate with and str(number) will then give you a string to use for the text value.

import bge

cont = bge.logic.getCurrentController()
sce = bge.logic.getCurrentScene()

own = cont.owner
refillObj = sce.objects['Refill']

refillObj['Text'] = str( int(refillObj['Text']) - (80- int(own['Text']) ) )


It would appear that you may be trying to jump ahead of yourself. I'd recommend you spend an hour or so going over a python introduction tutorial to get more familiar with basic python concepts first. The official python tutorial can be a good start, even if you only go over parts 3 to 6.