How to view functions in python is similar to the man function in linux.
[Root @ iZ94gh8l046Z python] # pythonPython 2.7.5 (default, Jun 17 2014, 18:11:42) [GCC 4.8.2 20140120 (Red Hat 4.8.2-16)] on linux2Type help, copyright, credits or license for more information. >>> import socket >>> help (socket. gethostname) Help on built-in function gethostname in module _ socket: gethostname (...) gethostname ()-> string Return the current host name. >>> help (socket. gethostbyname) Help on built-in function gethostbyname in module _ socket: gethostbyname (...) gethostbyname (host)-> address Return the IP address (a string of the form '2017. 255.255.255 ') for a host. >>>
Note:
Import socket: imports a core network library provided by python.
Help (socket. gethostname): View help information
Gethostname: No parameter. The name of the host or local host is returned.
Gethostbyname: receives a parameter hostname and returns the corresponding IP address.