Bytearray Methods
bytearray.upper()
Map lowercase ASCII letters a–z to A–Z. Digits, punctuation, controls and byte values above 127 do not change. Unlike Unicode uppercasing this transformation never expands a character into multiple bytes. Returns a new mutable buffer even when no changes are needed; the original is untouched. These operations are intended for ASCII-compatible data, not arbitrary binary formats.
Formal Syntax & Structure
python syntaxpython
data.upper()Return Value
bytearray
bytearray containing the transformed byte values; receiver unchanged.
Working Example
Example Snippetpython
data = bytearray(b'api-ready 7')result = data.upper()print(result)print(bytearray(b'\xc3\x9f').upper())print(data)print(result is data)