ch02
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
# bytearray.py
|
||||
|
||||
|
||||
>>> bytearray() # empty bytearray object
|
||||
bytearray(b'')
|
||||
>>> bytearray(10) # zero-filled instance with given length
|
||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
|
||||
>>> bytearray(range(5)) # bytearray from iterable of integers
|
||||
bytearray(b'\x00\x01\x02\x03\x04')
|
||||
>>> name = bytearray(b'Lina') #A - bytearray from bytes
|
||||
>>> name.replace(b'L', b'l')
|
||||
bytearray(b'lina')
|
||||
>>> name.endswith(b'na')
|
||||
True
|
||||
>>> name.upper()
|
||||
bytearray(b'LINA')
|
||||
>>> name.count(b'L')
|
||||
1
|
||||
Reference in New Issue
Block a user