临时解决办法:
查找端口被占用的进程,然后强制结束
lsof -i:9090
然后kill对应的进程
#--coding:utf-8--
from http.server import BaseHTTPRequestHandler, HTTPServer
import time
import socket
class CarServer(BaseHTTPRequestHandler):
def get_host_ip(self):
def do_GET(self):
self.send_response(200)
self.send_header("Content-type", "text/html")
self.end_headers()
self.wfile.write("Hello World !".encode())
if name == "main":
socket.set
myServer = HTTPServer(("192.168.1.101", 9090), CarServer)
print(time.asctime(), "Server Starts - %s:%s" % ("a","b"))
try:
myServer.serve_forever()
except KeyboardInterrupt:
pass
原文:http://blog.51cto.com/13831725/2132173