CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Threaded View

  1. #2
    Join Date
    Mar 2008
    Posts
    5

    Re: Python Line parser

    If I think I know what you mean, this code should extract the parts of one line and iterate through a range of IP's, passing each one to a function I'm presuming you already have called "check_ip" which takes an IP in string format.

    Code:
    parts = line.split(".")
    first_part = parts[:-1]
    last_part = parts[-1]
    the_range = last_part.split("-")
    bottom = the_range[0]
    top = the_range[1]
    
    for i in range(int(bottom), int(top)+1):
        ip = ".".join(first_part) + "." + str(i)
        check_ip(ip)
    Last edited by Sharkey; March 31st, 2008 at 09:41 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured