1.
>>>import socket
>>>hostname = socket.gethostname()
'OOooo-PC'
>>>ip = socket.gethostbyname(hostname)
>>>print ip
'172.8.4.16'
>>> ipList = socket.gethostbyname_ex(hostname)
>>> ipList
('OOooo-PC', [], ['172.8.4.16', '10.5.48.93'])
2.
>>> name = socket.getfqdn(socket.gethostname())
>>> name
'OOooo-PC'