Skip to content

Instantly share code, notes, and snippets.

@profiprog
Created May 24, 2021 11:23
Show Gist options
  • Save profiprog/cf608d80444013cea82cfb461252f62a to your computer and use it in GitHub Desktop.
Save profiprog/cf608d80444013cea82cfb461252f62a to your computer and use it in GitHub Desktop.
One line code
ip2bin = lambda ip: ' '.join([bin(int(n))[2:].zfill(8) for n in ip.split(".")])
bin2ip = lambda ip: '.'.join([str(int(n,2)) for n in ip.split(' ')])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment