def my_func():
    """
    this function return some value
    :return:
    """
return 25.256

def write_file(data):
    """
    this function write data to file
    :param data:
    :return:
    """
file_name = 'D:\\log.txt'
with open(file_name, 'wb') as x_file:
    x_file.write('{} TotalAmount'.format(data))

def run():
    data = my_func()
write_file(data)
run()
Python Print String To Text File