Home  »  CodeProgrammingSnippetsTechnologyTools   »   Python get Public IP Address

Python get Public IP Address

Posted: March 16, 2022 | by Michael Bright

Python get public ip address example. This example requires the requests library to be installed.

from requests import get

ip = get('http://local.brightwhiz').text
print(f'My public IP address is: {ip}')

More about the Requests library here: http://docs.python-requests.org/en/latest/

Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.