I want to output the following format:
addr<-9->bit<-15->value<-13->name<-26->type
.... ... ...... ...... ...... #..... is the content of each row
I used the str.format to achieve it:
STRING_FORMATTER = '{0:13}{1:18}{2:18}{3:30}{4:10}\n'
content = STRING_FORMATTER.format('addr', 'bit', 'value', 'name', 'type')
content = content + STRING_FORMATTER.format('0123', 'LONG STRING THAT EXCEEDS 18 SPACES!!!!!!!!!!!!!!!!', '', '', 'reg')
content = content + STRING_FORMATTER.format('00', '0', '0xAD', 'NAME', 'bit')
.....
I basically construct the string by the type. The above is a problem that when the 2nd string exceeds 18 char spaces, the string behind is pushed. Is there a way to solve it?
Or is there a better way to format the string to start at a fixed spacing in front?