Advertisement
asapka

Untitled

Feb 7th, 2020
566
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. ip_list = ['192.168.1.25','172.16.1.40']
  2. full_bin_ip = []
  3. len_ip = 8
  4. for address in ip_list:
  5. splitted_address = address.split('.')
  6. for octet in splitted_address:
  7. bin_split_ip = bin(int(octet))
  8. correct_bin_ip = bin_split_ip[2:]
  9. len_split_ip = len(correct_bin_ip)
  10. correct_len_ip = len_ip - len_split_ip
  11. if len_split_ip < 8:
  12. full_octet_ip = '0' * correct_len_ip + correct_bin_ip
  13. full_bin_ip.append(full_octet_ip)
  14. else:
  15. full_bin_ip.append(correct_bin_ip)
  16. full_bin_ip.append(address)
  17. print(full_bin_ip)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement