all Python 3Byte sequencesfunction
bytes.upper
bytes — case
Return a copy with ASCII letters upper-cased.
Syntax
b.upper(...)
Only ASCII A-Z/a-z change, because a bytes object carries no information about its encoding: calling upper() on UTF-8 encoded Cyrillic or accented text leaves every byte exactly as it was. For real Unicode case conversion, decode to str first, call str.upper() there, and encode the result back.
Examples
print(b'abc'.upper()) # → b'ABC'
print(b'py 3.12 rocks'.upper()) # → b'PY 3.12 ROCKS'
print(b'MiXeD'.lower()) # → b'mixed'
print(b'Yes'.upper() == b'YES') # → True
print('привет'.encode().upper() == 'привет'.encode()) # → True
See also
Open in the full glossarydocs.python.orgReport an inaccuracy