値を使用してテーブルをフォーマットしようとしていますが、やり方が悪いと感じています。たとえば、分割して文字列に渡すときに、int の辞書を int に変換する必要があります。また、 %f は大量の 0 を出力するようです。末尾のすべての 0 ではなく、小数点を使用した除算が必要なだけです
band1= {'channel1': 10564, 'channel2': 10589, 'channel3': 10612, 'channel4': 10637,'channel5': 10662, 'channel6': 10687,
'channel7': 10712, 'channel8': 10737, 'channel9': 10762, 'channel10': 10787,'channel11': 10812, 'channel12': 10837, }
print '%10s %10s %10s %10s %10s %10s %10s %10s %10s %10s %10s %10s' % ("Channel 1", "Channel 2", "Channel 3",
"Channel 4", "Channel 5", "Channel 6", "Channel 7","Channel 8", "Channel 9", "Channel 10", "Channel 11", "Channel 12")
print '%10s %10s %10s %10s %10s %10s %10s %10s %10s %10s %10s %10s' % (band1['channel1'], band1['channel2'], band1['channel3'],
band1['channel4'], band1['channel5'], band1['channel6'], band1['channel7'], band1['channel8'], band1['channel9'],
band1['channel10'], band1['channel11'], band1['channel12'])
print '%5f %5f %5f %5f %5f %5f %5f %5f %5f %5f %5f %5f' % (int(band1['channel1'])/5.0, int(band1['channel2'])/5.0, int(band1['channel3'])/5.0,
int(band1['channel4'])/5.0, int(band1['channel5'])/5.0, int(band1['channel6'])/5.0, int(band1['channel7'])/5.0, int(band1['channel8'])/5.0, int(band1['channel9'])/5.0,
int(band1['channel10'])/5.0, int(band1['channel11'])/5.0, int(band1['channel12'])/5.0)
これは与える:
Channel 1 Channel 2 Channel 3 Channel 4 Channel 5 Channel 6 Channel 7 Channel 8 Channel 9 Channel 10 Channel 11 Channel 12
10564 10589 10612 10637 10662 10687 10712 10737 10762 10787 10812 10837
2112.800000 2117.800000 2122.400000 2127.400000 2132.400000 2137.400000 2142.400000 2147.400000 2152.400000 2157.400000 2162.400000 2167.400000