Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 81373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T21:26:59+00:00 2026-05-10T21:26:59+00:00

I have a string with a length that is a multiple of 8 that

  • 0

I have a string with a length that is a multiple of 8 that contains only 0’s and 1’s. I want to convert the string into a byte array suitable for writing to a file. For instance, if I have the string ‘0010011010011101’, I want to get the byte array [0x26, 0x9d], which, when written to file, will give 0x269d as the binary (raw) contents.

How can I do this in Python?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T21:27:00+00:00Added an answer on May 10, 2026 at 9:27 pm
    py> data = '0010011010011101' py> data = [data[8*i:8*(i+1)] for i in range(len(data)/8)] py> data ['00100110', '10011101'] py> data = [int(i, 2) for i in data] py> data [38, 157] py> data = ''.join(chr(i) for i in data) py> data '&\x9d' 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string of digits that could vary in length and I want
I have a variable length array of strings declared in javascript that contains Dungeons
I have a table that contains in one column a variable length delimited string
I have a string that contains multiple parameters delimited by #, like this :
I have a string that says 15:00:00 how can I limit the length of
I need to have a string that has a specified length and replace the
I have 4 string arrays,each of these array's length is 4. I also have
Let's say I have string of length in multiple of 3. my $seq =
I have a parent folder that contains inside it multiple folders named Project-* (folders
I have an arraylist with multiple hashmaps that contains information that comes from a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.