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 1019561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:01:56+00:00 2026-05-16T11:01:56+00:00

I want to convert an ip address read from a file in the decimal

  • 0

I want to convert an ip address read from a file in the decimal format (192.168.65.72) to one in binary format {110000001010100001000001010001000}.I am reading the ip address in the decimal format from a file.Find the code snippet below.

/*contains 192.168.65.72*/
filter = open("filter.txt", "r")

for line in filter:
    bytePattern = "([01]?\d\d?|2[0-4]\d|25[0-5])"
    regObj = re.compile("\.".join([bytePattern]*4))
    for match in regObj.finditer(line):
        m1,m2,m3,m4 = match.groups()
        print "%s %s %s %s" %(m1, m2, m3, m4)

I want to convert m1,m2,m3 and m4 each into an 8bit binary value.I cannot figure out a way to do that.I am new to python.Any help will be greatly appreciated.

Cheers.

  • 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. Editorial Team
    Editorial Team
    2026-05-16T11:01:57+00:00Added an answer on May 16, 2026 at 11:01 am
    ''.join([ bin(int(x))[2:].rjust(8,'0') for x in '123.123.123.123'.split('.')])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Question: When I convert the IP address 192.168.115.67 to a number, is it done
I want to write network address to my listview, in a range like 192.168.0.0
I have a mac address in this format 00:45:36:45:f2:00 I want to convert this
I want to convert XML into binary data in Java? What is the fastest
I want to convert sqlite query to Ormlite query. SELECT * FROM Test where
I want to convert a 44,100 Hz, 24 Bit Mono wav file to aformat
I have a guestbook, and I want to convert site address in the following
How to convert the Address into Latitude and Longitude in Objective C? I want
Here is my code.. I want to find just a name of city from
I want to read a sequence of bytes from my accelerometer. I can't get

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.