String representation of integers with comma-separated thousands

Python can produce string representations of numbers for which thousands are separated by commas:

>>> '{:11,d}'.format(1000000)
'  1,000,000'
>>> '{:11,.1f}'.format(1000000.)
'1,000,000.0'

Here is another table, produced using several different string methods:

title = '|' + '{:^51}'.format('Cereal Yields (kg/ha)') + '|'
line = '+' + '-'*15 + '+' + ('-'*8 + '+')*4
row = '| {:<13} |' + ' {:6,d} |'*4
header = '| {:^13s} |'.format('Country') + (' {:^6d} |'*4).format(1980, 1990,
                                                                  2000, 2010)
print('+' + '-'*(len(title)-2) + '+',
      title,
      line,
      header,
      line,
      row.format('China', 2937, 4321, 4752, 5527),
      row.format('Germany', 4225, 5411, 6453, 6718),
      row.format('United States', 3772, 4755, 5854, 6988),
      line,
      sep='\n')

The output is:

+---------------------------------------------------+
|               Cereal Yields (kg/ha)               |
+---------------+--------+--------+--------+--------+
|    Country    |  1980  |  1990  |  2000  |  2010  |
+---------------+--------+--------+--------+--------+
| China         |  2,937 |  4,321 |  4,752 |  5,527 |
| Germany       |  4,225 |  5,411 |  6,453 |  6,718 |
| United States |  3,772 |  4,755 |  5,854 |  6,988 |
+---------------+--------+--------+--------+--------+