My file contains IP addresses that I'd like to convert to host names. The IP addresses are the same except for the last three octets. For example:
192.168.38.8
192.168.38.9
192.168.38.10
I have the following code in my python script to substitute the IP address with the host name which ends in the final octet.
hostname = re.sub('192.168.38.','Host-Name',lm.group(4))
This give me the results:
Host-Name8
Host-Name9
Host-Name10
How do I get the single digit octets to have a leading zero? The desired output would be;
Host-Name08
Host-Name09
Host-Name10