import requests
import re

def get_ip_by_ip138():
    response = requests.get("http://www.baidu.com")
    ip = re.search(r"\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]",response.content.decode(errors='ignore'))
    return ip

print("本机的ip地址为:",get_ip_by_ip138())
dd31fda48807861e058afec7e46f56bd16c2d4d5
<mask token>

<mask token>


def get_ip_by_ip138():
    response = requests.get('http://www.baidu.com')
    ip = re.search('\\[\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\]',
        response.content.decode(errors='ignore'))
    return ip


<mask token>

<mask token>


def get_ip_by_ip138():
    response = requests.get('http://www.baidu.com')
    ip = re.search('\\[\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\]',
        response.content.decode(errors='ignore'))
    return ip


print('本机的ip地址为:', get_ip_by_ip138())

import requests
import re


def get_ip_by_ip138():
    response = requests.get('http://www.baidu.com')
    ip = re.search('\\[\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\]',
        response.content.decode(errors='ignore'))
    return ip


print('本机的ip地址为:', get_ip_by_ip138())

import requests
import re

def get_ip_by_ip138():
    response = requests.get("http://www.baidu.com")
    ip = re.search(r"\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]",response.content.decode(errors='ignore'))
    return ip

print("本机的ip地址为:",get_ip_by_ip138())