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 winforms application i have been working on that runs multiple tests
I want to have immutable types that can, ideally, sort out their own hashing
I'm writing a utility in C# that will make managing multiple Mercurial repositories easier
I am trying to allow multiple file uploads prior to a form post. What
i need to read files that look like this into a datatable: A02 BLANK031
Hello: I want to do a weighted search on product that are tagged with
I have a multi-line TextView that has android:ellipsize=end set. I would like to know,
I'm trying to set up a CTFrame that exactly matches my UITextView 's text
I have a project where I generate lots of code against many XSD. To
For the last project of the semester, the goal is to run searches of

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.