byte

Loading compressed baboon interaction data in Python

Loading compressed baboon interaction data in Python Question: I am interested in reading the observational data and wearable sensor data available here into Python. Specifically, I would like to get them into Pandas dataframes, but even getting them into a more familiar form would effectively answer the question. Both files are *.txt.gz files. I have …

Total answers: 1

AES key (string) input, unable to be converted to corresponding byte sequences correctly

AES key (string) input, unable to be converted to corresponding byte sequences correctly Question: My python program takes a AES key as input. For example, xee~xb0x94Lhx9fnr?x18xdfxa4_7Ixf7xd8T?x13xd0xbd4x8eQx9bx89xa4cxf9xf1 This string input must now be converted back to a byte sequences, so that the key can be used in decryption. aes_key = str.encode(user_input) # user_input being the key …

Total answers: 1

Why I get this output while I trying to print this packed struct?

Why I get this output while I trying to print this packed struct? Question: I running this code in python: import struct res = struct.pack(‘hhl’, 1, 2, 3) print(res) and I get the following output: b’x01x00x02x00x00x00x00x00x03x00x00x00x00x00x00x00′ but I don’t understand why this is the output? after all, the format h means 2 bytes, and the …

Total answers: 1

How to do a Circular left shift for a byte in python

How to do a Circular left shift for a byte in python Question: I am trying to do a left-byte shift on a list. But it is not working properly. def left_byte_shift(w3): temp = w3 x=0 a = (len(w3)-1) print("a=",a) for i in reversed(range(len(w3))): if i == a: #3 w3[x] = temp[a] else: #2,1,0 print(w3[i],temp[i+1]) …

Total answers: 2

convert byte to string represented with backslahes in python

convert byte to string represented with backslahes in python Question: I have a python byte object like a = b’1′ I want to convert to string like "\x31" is there any easy way to do this? Ultimately I have a byte object like my_obj = b’x00$x00x00x001.1.0.00x00x00x00x00x00x00x00x001.1.0.21152x00x00′ and I want it to have a string with …

Total answers: 1

Converting integers to bytes – how does the calculation work

Converting integers to bytes – how does the calculation work Question: I am trying to use Python bytes methods to convert integers to bytes. I know there are different approaches to do this in Python, but I would like to do this using just the bytes method, which requires to understand how this is done …

Total answers: 2

how to convert bytes to binary using python

how to convert bytes to binary using python Question: so i want convert bytes to binary in python, but when i run it, there’s none in the result and i got error: ‘NoneType’ object is not iterable here’s the code i tried //func biner def biner(password): print(password) password[0] for my_byte in password: print(f'{my_byte:0>8b}’, end=’ ‘) …

Total answers: 2

How to convert to MB or KB the pandas describe table?

How to convert to MB or KB the pandas describe table? Question: df.describe() I have a network dataset. To be able to understand the dataset better, I want to find a way to convert the numbers to MB or KB for packets and bytes. df.head() Asked By: linuxpanther || Source Answers: You could just divide …

Total answers: 1

Send in-memory bytes (file) over multipart/form-data POST request. Python

Send in-memory bytes (file) over multipart/form-data POST request. Python Question: ;TLDR I want to send a file with requests.send() using multipart/form-data request without storing the file on a hard drive. Basically, I’m looking for an alternative for open() function for bytes object Hello, I’m currently trying to send multipart/form-data request and pass in-memory files in …

Total answers: 1