即使撇号后面的字母也要大写,这不是预期的结果
>>> test = "there's a need to capitalize every word"
>>> test.title()
"There'S A Need To Capitalize Every Word"
有些人建议使用capwords,但capwords似乎有缺陷(仅
大写单词前面加空格)。在这种情况下,我还需要能够大写由句点分隔的单词(例如:一、二、三结果应该是一、二、三). 在
有没有一种方法在capwords和title中不会失败?在
Tags:
在python的文档中有一个解决问题的方法,here:
您可以在
re.sub
的替换部分使用匿名函数使用string.capwords
相关问题 更多 >
编程相关推荐