我想找到一种方法,如何更改python中句点(。)之后的第一个字母?
示例:
hello world. this is test. please help
我想要的结果是:
Hello world. This is test. Please help.
我试过这样,但它不起作用:
text = 'hello world. this is test. please help'
print text.capitalize()
答案 0 :(得分:3)
试试这个:
sentence = "hello world. this is test. please help."
print(". ".join(i.capitalize() for i in sentence.split(". ")))