Skip to content

Instantly share code, notes, and snippets.

@ethinx
Last active July 1, 2021 06:37
Show Gist options
  • Save ethinx/7636432 to your computer and use it in GitHub Desktop.
Save ethinx/7636432 to your computer and use it in GitHub Desktop.
inet_addr in Python
python -c 'import socket,struct; print(hex(struct.unpack("<L", socket.inet_aton("127.0.0.1"))[0]))'
@ye
Copy link

ye commented Jul 10, 2015

You are missing a closing paren at the end and misspelled "struct" :(
python3 -c 'import socket,struct; print(hex(struct.unpack("<L", socket.inet_aton("127.0.0.1"))[0]))' would work

@ethinx
Copy link
Author

ethinx commented Aug 16, 2015

@ye thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment