Nov-14-2021, 05:33 AM
(This post was last modified: Nov-14-2021, 05:33 AM by deanhystad.)
iimport socket HEADERSIZE=10 msg = "Welcome to the server!" print(len(msg)) x = f'{len(msg):<10{HEADERSIZE}}'+msg y = f'{len(msg):<1010}'+msg print(len(x), len(y), x == y)
Output:1032 1032 True
10{HEADERSIZE} ends up as 1010. The resulting string is 1032 characters long. 1010 character for the message length and padding and 22 characters for the message.If I print x it looks like this:
Output:22
Welcome to the server!
This is "22" followed by 1008 blanks and then "Welcome to the server!"