I am converting bash code to python code. I got a global ip address of the own host in bash code by
hostname -I # output -> 19x.xxx.xxx.xxx xxxx:xxxx:....
The 19x.xxx.xxx.xxx is the global ip address of the own host.
I tried to get the global ip address in python by
import socket
name=socket.gethostname()
id_address=socket.gethostbyname(name)
print("id_address = {0}".format(id_address))
The output was the local host address like
127.xxx.xxx.xxx
Do I have a way to get a global ip address in python?