from pyroute2 import IPRoute
ip = IPRoute()
info = [{'iface': x['index'], 'addr': x.get_attr('IFA_ADDRESS'), 'mask': x[
    'prefixlen']} for x in ip.get_addr()]
ip.close()
Get network address and network mask in Python