Returns the length of a string in bytes.
str.encode()
to encode the given string and return its length.def byte_size(s):
return len(s.encode('utf-8'))
byte_size('๐') # 4
byte_size('Hello World') # 11
Python, String
Pads a string on both sides with the specified character, if it's shorter than the specified length.
Python, String
Pads a given number to the specified length.
Python, String
Converts a hexadecimal color code to a tuple of integers corresponding to its RGB components.