新手提问关于title()问题
1.错误
def describe_city(city_name,city_country='china'): print(city_name.title()+' is '+city_country.tilte())
报错:'str' object has no attribute 'tilte'
2.改正
当我改成以下格式后:
def describe_city(city_name,city_country='china'): city_name=city_name.title()
city_country=city_country.title()
print(city_name+' is in '+city_country)
运行,不会出现报错,我想知道这是为什么,请各位前辈指教
回答:
'str' object has no attribute 'tilte'
tilte
不是 title
,拼错了。
以上是 新手提问关于title()问题 的全部内容, 来源链接: utcz.com/p/938350.html