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://codercto.com/courses/l/8.html

查看所有标签

Algorithm Design

Algorithm Design

Jon Kleinberg、Éva Tardos / Addison-Wesley / 2005-3-26 / USD 144.20

Algorithm Design introduces algorithms by looking at the real-world problems that motivate them. The book teaches students a range of design and analysis techniques for problems that arise in compu......一起来看看 《Algorithm Design》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具