Question:
I'm trying to convert an array to a string and add the "|" to it at the beginning and end of each field
Below is the example array
['', 'C170', '1', '14879', '', '1,00000', 'UN', '29,99', '0,00', '1', '060', '1407',
'NE09', '0,00', '0,00', '0,00', '0,00', '0,00', '0,00', '0', '49', '', '0,00', '0,00',
'0,00', '99', '0,00', '0,00', '', '', '0,00', '99', '0,00', '0,00', '', '', '0,00',
'3010107010057', '\n']
Answer:
"|".join(a)
produces a string with the elements separated by "|"
'|C170|1|14879||1,00000|UN|29,99|0,00|1|..... 3010107010057|\n'
Joining "|" at the beginning and end:
"|" + "|".join(a) + "|"
Where
"|%s|" % "|".join(a)
from the
'||C170|1|14879||1,00000|UN|29,99|0,00|1|..... 3010107010057|\n|'
is this what you want?