Python字串函式capitalize的用法:首字母大寫
阿新 • • 發佈:2021-01-27
技術標籤:# 4.2 Pythonpython字串strcapitalize
str.capitalize()
返回原字串的副本,其首個字元大寫,其餘為小寫
# coding:utf-8
name = '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)