Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON: How do I split up the binary string into chunks of 8 so that they are converted from binary to ASCII characters? For example

PYTHON: How do I split up the binary string into chunks of 8 so that they are converted from binary to ASCII characters? For example "0011101000101001" would be eventually converted to ":)" . The code I have below is what I currently have. It currently only works for binary strings of 8. argv[1] is the text file it is reading from and argv[2] is basically just 8.

import sys filename=sys.argv[1] length = int(sys.argv[2]) message_data = open(filename, "r") message_text = message_data.read() if len(message_text) == 0: sys.exit(1) a= message_text.replace(',','') a= ''.join(a.split()) conversion_list =[128, 64, 32, 16, 8, 4, 2, 1] dec=0 for position, digit in enumerate((a)): dec += conversion_list[position]* int(digit) print("Decimal is ",dec) e=chr(dec)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Horse Betting The Road To Absolute Horse Racing 2

Authors: NAKAGAWA,YUKIO

1st Edition

B0CFZN219G, 979-8856410593

More Books

Students also viewed these Databases questions

Question

Give a brief defi ni tion of the terms population and sample.

Answered: 1 week ago