练习8-3:这里我们可以使用换行符,使表达更直观简洁。
def make_shirt(size,word):
print(f"The shirt's size is {size}.")
print(f"\nThe shirt's word is {word}.")
make_shirt("m",'superman')
练习8-4:
def make_shirt(size='l',word='I love python'):
print(f"The shirt's size is {size.upper()}.")
print(f"\nThe shirt's word is {word.title()}.")
make_shirt()
make_shirt(size="m")
make_shirt(word='i love c')
练习8-5:关键在于f字符串的利用
def descirbe_city(city,country):
print(f"{city.title()} is in {country.title()}.")
descirbe_city('reykjavik','iceland')