Titlecasing a string with exceptions
问题 Is there a standard way in Python to titlecase a string (i.e. words start with uppercase characters, all remaining cased characters have lowercase) but leaving articles like and , in , and of lowercased? 回答1: There are a few problems with this. If you use split and join, some white space characters will be ignored. The built-in capitalize and title methods do not ignore white space. >>> 'There is a way'.title() 'There Is A Way' If a sentence starts with an article, you do not want the first