#'="2409:8C20:1833::"&DEC2HEX(MID(BF4,1,2),2)&DEC2HEX(MID(BF4,4,3),2)&":"&DEC2HEX(MID(BJ4,8,2),2)&"FE"'
'''
十进制转化为16进制ip地址
'''

#拆分ipv4地址为列表
# a='10.172.178.1'
# print(a.split('.',4))
# b=a.split('.',4)
#转化为二进制
# #print(str(bin(int(b[0]))).replace('0b',''))
# c=str(bin(int(b[0]))).replace('0b','')
#二进制转化为16进制
# print(str(hex(int(c,2))).replace('0x','').upper())
#import insert_ip


def ipv4toipv6(ipv4, ipv6,temp=1):
    if ipv4 != None and ipv4 != "\\" and ipv4 !='无业务网':
        print("ipv4:",type(ipv4),ipv4)
        list=ipv4.split('.',4)
        for b in list:
            tmp = str(bin(int(b))).replace('0b', '')
            hexadecimal = str(hex(int(tmp, 2))).replace('0x', '').upper()
            if len(hexadecimal) < 2:
                hexadecimal = '0'+hexadecimal
            if temp == 2:
                temp+=1
                ipv6=ipv6+hexadecimal+':'
            else:
                temp += 1
                ipv6 = ipv6 + hexadecimal

        return  ipv6
    else:
        return None



# if __name__ == '__main__':
#     print(ipv4toipv6('192.168.70.20','2409:8C20:1833::'))
#     list = insert_ip.service_network("业务网")
#     for i in list:
#         i.append(ipv4toipv6(i[1], '2409:8C20:1833::'))
#         i.append(ipv4toipv6(i[4], '2409:8C20:1833::'))
#     print(list)