本文主要是介绍Python字符串函数capitalize的用法:首字母大写,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
str.capitalize()
返回原字符串的副本,其首个字符大写,其余为小写
# coding:utf-8name = 'xiao mu'
info = 'hello 小慕'
_info = '小慕 hello'
number_str = '1314'new_name = name.capitalize()
new_info = info.capitalize()
_new_info = _info.capitalize()
new_number_str = number_str.capitalize()print(new_name,"<-", name)
print(new_info,"<-", info)
print(_new_info,"<-",_info)
print(new_number_str,"<-",number_str)
这篇关于Python字符串函数capitalize的用法:首字母大写的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!