数字字符串转IP

python:

IP_MOD_BASE = 256

def ipstr_to_ip2(ipstr):
    a = int(ipstr)
    c , b = divmod(a, IP_MOD_BASE)
    e, d = divmod(c, IP_MOD_BASE)
    g, f = divmod(e, IP_MOD_BASE)
    tmp, h = divmod(g, IP_MOD_BASE)
    return str(h) + "." + str(f) + "." + str(d) + "." + str(b)