Python capitalize()方法
Python 教程
· 2019-02-02 09:29:42
描述
Python capitalize()将字符串的第一个字母变成大写,其他字母变小写。对于 8 位字节编码需要根据本地环境。
语法
capitalize()方法语法:
str.capitalize()
参数
- 无。
返回值
该方法返回一个首字母大写的字符串。
实例
以下实例展示了capitalize()方法的实例:
>>>s = 'a, B'
>>> s.capitalize()
'A, b'
>>> s = ' a, B' # a 前面有空格
>>> s.capitalize()
' a, b'
>>> s = 'a, BCD'
>>> s.capitalize()
'A, bcd'
点击查看所有 Python 教程 文章: https://www.codercto.com/courses/l/8.html
Programming Collective Intelligence
Toby Segaran / O'Reilly Media / 2007-8-26 / USD 39.99
Want to tap the power behind search rankings, product recommendations, social bookmarking, and online matchmaking? This fascinating book demonstrates how you can build Web 2.0 applications to mine the......一起来看看 《Programming Collective Intelligence》 这本书的介绍吧!