首字母大写
此代码段将用于将字符串中字符的每个首字母大写。它可以处理具有一个或多个字符的字符串,这将在文本分析或将数据写入文件等中派上用场。
def capitalize(String):
return String.title()
capitalize("shop") # [Shop]
capitalize("python programming") # [Python Programming]
capitalize("how are you!") # [How Are You!]
首字母大写
此代码段将用于将字符串中字符的每个首字母大写。它可以处理具有一个或多个字符的字符串,这将在文本分析或将数据写入文件等中派上用场。
def capitalize(String):
return String.title()
capitalize("shop") # [Shop]
capitalize("python programming") # [Python Programming]
capitalize("how are you!") # [How Are You!]