I have a task that requires me to encapsulate multiple functions, each with one or more outputs.At present, the function has been encapsulated and the calling program has been written, which can output the result of the function to the computer screen.How to call the results of the function output to a txt file, and can be written in the original format (the line when the line) to txt.
The function is called successfully and outputs the results to the computer screen.
This is the part of the code that calls the function and a simple function.
if len_1[3] == '1':
import DecodeField_015
Item015 = list_1[i]
DecodeField_015.DecodeField015(Item015)
i = i + 1
if len_1[4] == '1':
import DecodeField_071
Item071 = list_1[i]
DecodeField_071.DecodeField071(Item071)
i = i + 3
def DecodeField015(Input):
str1 = 0
print('\nData Item I021/015, Service Identification')
I015 = '{:08b}'.format(Input)
print('bits 8/1,Service Identification: ' + I015)
return str1
This is the simplest example of a function. There are more than 40 functions like this.How to write the output of more than 40 functions into the txt file in order of function call.