socket.inet_aton () in python

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • getmanup
    New Member
    • May 2010
    • 4

    socket.inet_aton () in python

    please try to help me out with this one....

    i am reading IP addresses from command line I need to convert them into their decimal equivalents...a nd priint them

    i have to use the socket.inet_ato n() function right ?

    but i am not able to print the converted value...

    like i am trying the code as

    print "decimal equivalent is = %d " %(socket.inet_a ton(sys.srgv[0]))

    but this doesnt print anything .... jsut the string written in the print statement is being displayed....
  • dwblas
    Recognized Expert Contributor
    • May 2008
    • 626

    #2
    Check your spelling
    print "decimal equivalent is = %d " %(socket.inet_a ton(sys.srgv[0]))

    And I would strongly suggest that you print sys.argv[0] to see what you are sending. In the future please add some print statements to your code and at least try to do some debugging yourself. Just a heads up, if you continue to ask this type of question you will get a reputation and no one will answer any of your questions. So your code should be, at the very least
    print "sending", sys.argv[0], "to inet"
    result = socket.inet_ato n(sys.argv[0])
    print "result received =", result, type(result)
    print "decimal equivalent is = %d " %(result)

    Comment

    Working...