Python2 code:
JavaScript
x
2
1
x = buffer(chr(0) * 32)
2
What is the python3 equivalent?
I tried to replace buffer with memoryview()
but than name error becomes a type error: TypeError: memoryview: a bytes-like object is required, not ‘str’.
I’m pretty sure that this should be a string and not a byte.
Can someone help me?
Buffer function for python 3+ IS NOT THE ANSWER!
Advertisement
Answer
Adapting answers from Buffer function for python 3+
JavaScript
1
2
1
x = memoryview(b'x00'*32)`
2
memoryview
expects bytes. Python 3 makes a distinction between bytes and strings now.