📅  最后修改于: 2020-09-20 14:28:18             🧑  作者: Mango
capitalize()
的语法为:
string.capitalize()
capitalize()
函数不带任何参数。
capitalize()
函数返回一个字符串 ,该字符串的首字母大写,所有其他字符均小写。它不会修改原始字符串。
string = "python is AWesome."
capitalized_string = string.capitalize()
print('Old String: ', string)
print('Capitalized String:', capitalized_string)
输出
Old String: python is AWesome
Capitalized String: Python is awesome
string = "+ is an operator."
new_string = string.capitalize()
print('Old String:', string)
print('New String:', new_string)
输出
Old String: + is an operator.
New String: + is an operator.