Converting string data to binary and decoding it in Python? -
i asked question, bit unclear.
if have line of data:
52, 123, 0, ./commands/command_fw_update.c, "testing string" 52, 123, 0, ./commands/command_fw_updat2e.c, "testing string2" how can convert data .bin file, read in data bin file string?
the data in desired format. if want copy input file file called input.bin, use shutil.copyfile:
# copy data .bin file: import shutil shutil.copyfile("input.txt", "input.bin") # read data string: open("input.bin") data_file: data = data_file.read() # now, convert string useful data, # parse way want. example, take # first number in each line , store # array called "numbers": data = [[field.strip() field in line.split(",")] line in data.splitlines()] numbers = [int(data[0]) data in data] print numbers
Comments
Post a Comment