capitalize的用法_Python字符串| 使用示例的capitalize()方法

capitalize的用法

capitalize() is an in-built method in Python, it returns the string in Capitalized case, in which first character of the sentence is in uppercase and rest of the characters are in lowercase.

capitalize()是Python中的内置方法,它以大写形式返回字符串,其中句子的第一个字符为大写,其余字符为小写。

Syntax:

句法:

 String.capitalize()

Parameter: None

参数:

Return type: It returns capitalize case string.

返回类型:返回大小写字符串。

Example:

例:

# str1
str1 = "Hello world, how are you?"
print str1.capitalize ()# str2
str2 = "HELLO WORLD, HOW ARE YOU?"
print str2.capitalize ()# str3
str3 = 


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部