The case for numbers:
a = 5 , b = 5.2,c = "123456789"
The most common right-alignment: print("%3d"%a) outputs 5 (details: two spaces before 5)
print("%10.3f"%b) Output 5.200 (details: 10 means the whole output takes up 10 spaces, decimal space counts, 3 means there are three decimal places, if not enough, make up 0)
print("%.3f"%b) outputs 5.200 (details: represents three digits after the decimal point, not enough to fill in with zeros)
The case of strings:
Same as numbers, except %s is used instead of %d, %f
print("%.3s"%c) Output 123
print("%10.3s"%c) Output 123 (details: 1 preceded by 7 spaces)
For left-aligned cases, just print("%-3d"%a) like this.
Personally, I feel that the print function is partially similar to the printf format in the C language.
Above this version of the opposite version of the print function left and right alignment details is all that I have shared with you, I hope to give you a reference, and I hope that you will support me more.