«string%s»%(param1)«string {} {}».format(1parm,2param)«string {1}{2}{1}».format(1param,2param)f«string {name} {a + b}»val = 'Geeks' print(f"{val}for{val} is a portal for {val}.")
import datetime today = datetime.datetime.today() print(f"{today:%B %d, %Y}")
Backslash Cannot be used in format string directly.
f"newline: {ord('\n')}"
newline = ord('\n') print(f"newline: {newline}")
/+info: https://www.python.org/dev/peps/pep-0498/ /via: https://www.geeksforgeeks.org/formatted-string-literals-f-strings-python/
ljust(), rjust(), center()%15s, %15-s{:15}, {:>15}/via:https://www.delftstack.com/es/howto/python/python-pad-string-with-spaces/
zfill()n=42print(f'{n:05d}')print('%05d' % n)print('{0:05d}'.format(n))/via: https://www.python-engineer.com/posts/pad-zeros-string/
s1+s2«%s %s»%(s1,s2)«-».join([s1,s2])«{}{}».format(s1,s2)/via: https://www.tutorialspoint.com/how-to-concatenate-two-strings-in-python