可以拆分IP八位字节,然后将字符串中的八位字节转换为int,然后再转换回str。
>>> ip='10.00.01.10' >>> '.'.join([str(int(x)) for x in ip.split('.')]) '10.0.1.10'