Questions tagged [python-bytearray]

38 questions
0
votes
0 answers

Flask api not reading bytearray remotely but does locally

My client.py is as follows: import requests with open("image.jpg", "rb") as imageFile: # fil=imageFile.read() # print(fil) url = 'http://10.7.104.57:5000/julytest' headers = {'Content-Type': 'application/octet-stream'} try: …
Apricot
  • 2,925
  • 5
  • 42
  • 88
0
votes
0 answers

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 which were combined. This is how I tried it to…
Simon K
  • 28
  • 8
0
votes
1 answer

bytearray.reverse() not working within a class, is working when called on object

I have a class where in the initialization I set one member to a bytearray, and then another to its reverse by using the bytearray.reverse() function. When I instantiate the class, the "reversed" array is not reversed. If I then call reverse on the…
Daniel B.
  • 1,254
  • 1
  • 16
  • 35
0
votes
1 answer

Use variable value as bytes array in Python

I want to implement socket client in Python. The server expects the first 8 bytes contain total transmission size in bytes. In C client I did it like this: uint64_t total_size = zsize + sizeof ( uint64_t ); uint8_t* xmlrpc_call = malloc ( total_size…
pugnator
  • 665
  • 10
  • 27
-1
votes
1 answer

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 was wondering, because in this example it works. Thanks in…
kabr8
  • 341
  • 1
  • 2
  • 19
-1
votes
1 answer

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: def set_sampling(self, type, sampling_us): …
Shan-Desai
  • 3,101
  • 3
  • 46
  • 89
-2
votes
1 answer

Python adding cr to lf in binary data?

I was writing a python script which converts an ascii file containing one pair numbers per line to a straight binary representation. Here is my script: in_file = open("p02_0609.bin", 'r') out_file = open("sta013.bin", 'w') out_data =…
-4
votes
1 answer

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 255. Infact doing something like this: data =…
AndreaNobili
  • 40,955
  • 107
  • 324
  • 596
1 2
3