import socket def get_local_ip(): ''' 获取本地ip地址 :return: ''' s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) try: s.connect(('8.8.8.8', 80)) local_ip = s.getsockname()[0] except: local_ip.close() return local_ip print(get_local_ip()) import reque…