相对简单
class Solution:
def capitalizeTitle(self, title: str) -> str:
title_all = title.split()
title_new = []
for t_s in title_all:
if len(t_s) <= 2:
title_new.append(t_s.lower())
else:
title_new.append(t_s.capitalize())
return ' '.join(title_new)