Control if a input text is IP

Sbaush sbaush at gmail.com
Thu Feb 2 18:37:43 EST 2006


thanks!! your ipcheck is perfect fo me!!


2006/2/3, Fredrik Lundh <fredrik at pythonware.com>:
>
> Sbaush wrote:
>
> > My app has in input an ip address in IPv4 notation.
> > is there a function that control if input is a string in IPv4 notation?
>
> here's one way to do it:
>
> def ipcheck(s):
>     try:
>         a, b, c, d = [chr(int(c)) for c in s.split(".")]
>     except ValueError:
>         return False
>     else:
>         return True
>
> another way is to use regular expressions; see
>
>     http://www.regular-expressions.info/examples.html
>
> </F>
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



--
Sbaush
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20060203/6393bb54/attachment.html>


More information about the Python-list mailing list