What's the cleanest way to print an equally-spaced list in python?
问题 Please close if this is a duplicate, but this answer does not answer my question as I would like to print a list, not elements from a list. For example, the below does not work: mylist = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15] print(%3s % mylist) Desired output: [ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15] Basically, if all items in the list are n digits or less, equal spacing would give each item n+1 spots in the printout. Like setw in c++. Assume n is known. If I have missed a similar SO