Thank you for your answer Have a great day!
format
https://docs.python.org/ko/3/library/stdtypes.html#str.format
str.format(*args, **kwargs)
Performs a string format operation. The string to which this method is invoked can contain a substitution field separated by literal text or brackets {}. Each replacement field can have a numeric index of the position factor or the name of the keyword factor. Returns a copy of the string that replaces each substitution field with the value of the string for that factor.
>>> "{1} {3} {0} {2}".format("A", "B", "C", "D")
'B D A C'
https://docs.python.org/3/library/string.html#formatspec
It's all in the previously delivered link.
I think the first image is wrong For right-hand alignment, the command is >
.
I will omit the meaning of a for each example because Daewon summarized it.
# Setting the number of spaces
a = 123
b = f'{a:14}' # == f'{a:>14}'
print([b])
>> [' 123']
# Left Alignment
a = 123
b = f'{a:<14}'
print([b])
>> ['123 ']
# Centrally
a = 123
b = f'{a:^14}'
print([b])
>> [' 123 ']
© 2024 OneMinuteCode. All rights reserved.