All Questions
Tagged with python-bytearray python-3.x
17 questions
-1
votes
1
answer
89
views
How to XOR Hex ByteArray Elements [closed]
I'm trying to XOR all the elements in a bytearray, and generate the resulting checksum value in Hex. Finally, l will append the result to form a new bytearray. Sorry, I'm rusty in python now.
XorMath =...
0
votes
1
answer
270
views
python slice assignment and memoryview of bytearray
Sorry if my English is bad, I speak Korean as mother tongue.
I was writing code that changes bytearray partially.
And what I was trying to is to give name for memoryview of some sections of bytearray, ...
0
votes
1
answer
103
views
Trouble decoding malformed bytes to integer
I have a simple python socket server receiving "command" code that is encoded in ASCII. Most bytes are decoded properly with utf-8 by doing data.decode("utf-8"), but for some of ...
1
vote
1
answer
20
views
Compare every 3rd value inside a python dictionary and slice them
I have the following python dictionary with bytearray as values
test_bytearray_dict=
{'test_array0': bytearray(b'0000000000000000'),
'test_array1': bytearray(b'0000000001000000'),
'test_array2': ...
0
votes
0
answers
66
views
Unable to convert bytes to hex
I have a serial device (loadcell) connected to pc which is constantly sending data in a fixed format. It has 2 stop bits (0x40 and 0x0b). I am trying to read until 1 stop bit so I can start reading ...
1
vote
1
answer
474
views
How to store PagingState in Cassandra Python driver?
I'm implementing a REST API which behind the scenes queries Cassandra (via Python driver) and returns the result. Now the items to be queried will be huge so I want to have pagination capability.
The ...
-1
votes
1
answer
3k
views
Try to reverse an bytearray(from hex) in python
I have the following script:
hex_string = "c23dba5fcac1048b3c050266ceb6a0e870670021"
hex_bytes = bytearray.fromhex(hex_raw)
print(hex_bytes.reverse())
The problem it prints/returns None. I ...
5
votes
1
answer
2k
views
Python 3.73 inserting into bytearray = "object cannot be re-sized"
I'm working with a bytearray from file data. I'm opening it as 'r+b', so can change as binary.
In the Python 3.7 docs, it explains that a RegEx's finditer() can use m.start() and m.end() to ...
1
vote
1
answer
206
views
Behavior of byte arrays indexing in python 3
Run across this:
import sys; print('Python %s on %s' % (sys.version, sys.platform))
Python 3.7.6 (tags/v3.7.6:43364a7ae0, Dec 19 2019, 00:42:30) [MSC v.1916 64 bit (AMD64)] on win32
b'\n' == b'\n'
...
-4
votes
1
answer
1k
views
How exactly works the use of bytearray in Python?
I am absolutly new in Python and I have the following question.
From what I read on the documentation declaring a byte array I am not allowed to assign a value that doesn't come from the range 0 to ...
3
votes
2
answers
35k
views
TypeError: 'bytearray' object cannot be interpreted as an integer
I want to send audio data over HTTP, but I don't understand why I'm getting this exception:
Exception happened during processing of request from ('127.0.0.1', 59976)
Traceback (most recent call last):
...
1
vote
2
answers
9k
views
How to fetch bytes from SQL Server Database and Convert to Image in Python
-- I'm loading test data into my SQL Server Database using python and was able to successfully take images and break them down into bytes and store them in the database, but when trying to fetch ...
-1
votes
1
answer
30
views
discrepancy in results during conversion from int to bytes and vice versa provides in python3
I am using python3.4 in a venv.
I am writing a script for a sensor where, after reading a configuration file I need to send an int to the serial port in bytearray
a snippet of the class function is:
...
1
vote
1
answer
1k
views
Replacing byte in bytes array to fix encoding
I'm using ftfy to fix broken UTF-8 encoding that shows as CP1252 and convert it to UTF-8 cyrillic, but I've found that some letters can't be fixed.
I have a string Ð'010СС199 that I convert to ...
0
votes
0
answers
111
views
Creating Byte Object in Python3.x
I have a question considering python3. I am already trying for a few days to create a byte object, which looks like these:
b"'\x10\x00\x0020180425"
The first part '\x10\x00\x00 are two int16 objects ...