租用问题

质量为本、客户为根、勇于拼搏、务实创新

< 返回租用问题列表

python让所有单词首字母大写,python单词怎么发音

发布时间:2023-11-14 01:46:16

python让所有单词首字母大写

要将一个字符串中的所有单词的首字母大写,可使用字符串的 title() 方法。这个方法返回一个新的字符串,其中所有单词的首字母都大写。

下面是一个例子:

string = "hello world"
new_string = string.title()
print(new_string)

输出:

Hello World

在上面的例子中,字符串 "hello world" 中的每一个单词的首字母都被转换成了大写。