python获取请求ip地址

def get_request_ip(request):
    if request.META.get('HTTP_X_FORWARDED_FOR'):
        ip = request.META.get("HTTP_X_FORWARDED_FOR")
    else:
        ip = request.META.get("REMOTE_ADDR")
    return ip

你可能感兴趣的:(python,python,tcp/ip,网络)