my_favourites=['lamborghini',"sea facing resort",
'100 b dollar','3D animator']
line_1='and by that much money i want to own a '.title()+my_favourites[1].title()+' & a
'+my_favourites[0].upper()
print(line_1)
line_2=f'and by that much money i want to own a {my_favourites[1].title()} & a
{my_favourites[0].upper()}'
print(line-2)
#所以这里的问题是,连接很好,但我不知道如何将title方法应用于f-string语法中的初始文本,而不将该文本分配给额外的变量。
我承认f字符串有点奇怪:
f"{'and by that much money i want to own a'.title()} {my_favourites[1].title()} & {'a'.title()} {my_favourites[0].upper()}"
str.format
在这里更合适,我认为:
"and by that much money i want to own a {} & a {}".title().format(my_favourites[1].title(), my_favourites[0].upper())