29、f-Strings
f-string是格式化字符串的新语法。
与其他格式化方式相比,它们不仅更易读,更简洁,不易出错,而且速度更快!
num = 1
language = 'Python'
s = f'{language} is the number {num} in programming!'
print(s)
# Python is the number 1 in programming!
num = 1
language = 'Python'
s = f'{language} is the number {num*8} in programming!'
print(s)
# Python is the number 8 in programming!