get ip addresses from dhcp file
source link: https://gist.github.com/gitsysop/66cd29574bab8f56b83540dc7d65ec89
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
get ip addresses from dhcp file · GitHub
Instantly share code, notes, and snippets.
from mailbox import linesep import re
with open('dhcp') as f: lines = f.readlines() regexIp = '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}' iplist = re.findall(regexIp,str(lines)) print(iplist)
with open('myIpList', 'w') as fa: fa.writelines('\n'.join(iplist))
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK