* 在使用前,一定要注意在头部加上引用: using System.Net; 代码如下: using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Console.Write(new P
import socket def get_ip(): s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) try: # doesn't even have to be reachable s.connect(('10.255.255.255', 0)) IP = s.getsockname()[0] except: IP = '127.0.0.1' finally: s.close() return IP (来自百度知道) 利用socket