Python spacing and aligning strings
You should be able to use the format method:
"Location: {0:20} Revision {1}".format(Location, Revision)
You will have to figure out the format length for each line depending on the length of the label. The User
line will need a wider format width than the Location
or District
lines.
You can use expandtabs
to specify the tabstop, like this:
print(('Location: ' + '10-10-10-10' + '\t' + 'Revision: 1').expandtabs(30))print(('District: Tower' + '\t' + 'Date: May 16, 2012').expandtabs(30))
Output:
Location: 10-10-10-10 Revision: 1District: Tower Date: May 16, 2012