all Python 3Byte sequencesfunction
bytes.capitalize
bytes — case
Return a copy with the first byte upper-cased and the rest lower-cased.
Syntax
b.capitalize(...)
Only ASCII letters are touched: UTF-8-encoded Cyrillic or accented text comes back unchanged, so change case on the str and encode afterwards. Also note the tail is forced to lower case, which silently destroys internal capitals such as acronyms or CamelCase names.
Examples
print(b'hello'.capitalize()) # → b'Hello'
print(b'hELLO wORLD'.capitalize()) # → b'Hello world'
print(b'123ABC'.capitalize()) # → b'123abc'
print(b''.capitalize()) # → b''
print(b'hello world'.capitalize(), b'hello world'.title()) # → b'Hello world' b'Hello World'
See also
Open in the full glossarydocs.python.orgReport an inaccuracy