Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ip_list = ['192.168.1.25','172.16.1.40']
- full_bin_ip = []
- len_ip = 8
- for address in ip_list:
- splitted_address = address.split('.')
- for octet in splitted_address:
- bin_split_ip = bin(int(octet))
- correct_bin_ip = bin_split_ip[2:]
- len_split_ip = len(correct_bin_ip)
- correct_len_ip = len_ip - len_split_ip
- if len_split_ip < 8:
- full_octet_ip = '0' * correct_len_ip + correct_bin_ip
- full_bin_ip.append(full_octet_ip)
- else:
- full_bin_ip.append(correct_bin_ip)
- full_bin_ip.append(address)
- print(full_bin_ip)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement