Python Glossary Русский

all Python 3Byte sequencesfunction

bytearray.lower

bytearray — case

Return a copy with ASCII letters lower-cased.

Syntax

ba.lower(...)

Even though bytearray is mutable, this method changes nothing in place: it hands back a new object, so the result has to be assigned somewhere or it is lost. Only ASCII A-Z is folded, regardless of system locale — bytes of UTF-8 text (Cyrillic, é) pass through untouched, so decode() first and use str.lower() when you are dealing with real text.

Examples

print(bytearray(b'ABC').lower())   # → bytearray(b'abc')
print(bytearray(b'Hello, World!').lower())   # → bytearray(b'hello, world!')
print(bytearray(b'YES').lower() == b'yes')   # → True
ba = bytearray(b'ABC')
print(ba.lower(), ba)   # → bytearray(b'abc') bytearray(b'ABC')
print(bytearray(b'\xc0Z').lower())   # → bytearray(b'\xc0z')

See also

Open in the full glossarydocs.python.orgReport an inaccuracy