How do you determine if an IP address is private, in Python?

前端 未结 7 1214
Happy的楠姐
Happy的楠姐 2020-12-02 18:48

In Python, what is the best way to determine if an IP address (e.g., \'127.0.0.1\' or \'10.98.76.6\') is on a private network? The code does not s

7条回答
  •  一生所求
    2020-12-02 19:39

    A few days after asking this question, I found out about this Google project, ipaddr-py, which appears to have some of the same functionality with respect to determining if an address is private (is_rfc1918). Apparently this will be standard in Python 3.1.

提交回复
热议问题