MRAB a écrit :
On Oct 19, 5:47 pm, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote:Pat a écrit :
(snip)
ip = ip[ :-1 ] ip =+ '9'or:ip = ip[:-1]+"9"
(snip)
>>> re.sub(r'^(((\d+)\.){3})\d+$', "\g<1>9", "192.168.1.1") '192.168.1.9're.sub(r'^(((\d+)\.){3})\d+$', "\g<1>9", "192.168.1.100")'192.168.1.9'The regular expression changes the last sequence of digits to "9" ("192.168.1.100" => "192.168.1.9") but the other code replaces the last digit ("192.168.1.100" => "192.168.1.109").
Mmm - yes, true.
ip = ".".join(ip.split('.')[0:3] + ['9'])
--
http://mail.python.org/mailman/listinfo/python-list
