How to get my network adapter IP with python?
<p>If I type "ipconfig" in cmd, its gives some IPs... I need the one who belongs to my network adapter\internal IP.
So. for example:
If I have 3 Ips:</p>

<pre><code>10.100.102.2
192.168.231.1
192.168.233.1
</code></pre>

<p>And I need the first one. How do I make python know that this is the one I need\The one belongs to my internal IP?</p>

<p>The solution for extracting the first <strong>IPv4</strong> address of ethernet adapter (Python on Windows):<br>
- used modules: <code>os</code>, <code>re</code></p>

<pre><code>import os, re

addresses = os.popen('IPCONFIG | FINDSTR /R "Ethernet adapter Local Area Connection .* Address.*[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*"')
first_eth_address = re.search(r'\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b', addresses.read()).group()

print(first_eth_address)
</code></pre>

python