Skip to content

Commit a2d853d

Browse files
authored
Create memeoryView.py
1 parent 476b5de commit a2d853d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

memeoryView.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Using bytes() function to create bytes
2+
b1 = bytes([65, 66, 67, 68, 69])
3+
print(b1)
4+
5+
# Creating a bytearray by encoding a string
6+
val = bytearray("Hello", 'utf-8')
7+
print(val)
8+
9+
data = bytearray(b'hello , world!')
10+
view = memoryview(data)
11+
print(view)
12+
13+
import array
14+
arr = array.array('i',[1,2,3 ,4,5])
15+
view = memoryview(arr)
16+
print(view)

0 commit comments

Comments
 (0)