标签:实现 new add web服务器 list imp == rom import
Python重新加载模块
from imp import reload reload(模块名)#重新载入模块,前提是模块已经导入
import socket def service_client(new_socket): try: request = new_socket.recv(1024) print(request) response = "HTTP/1.1 200 OK\r\n" response += "\r\n" response += "<p1>tcp_socket</p1>" new_socket.send(response.encode("utf-8")) new_socket.close() except: new_socket.close() def main(): tcp_socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM) tcp_socket.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1) tcp_socket.bind(("",80)) tcp_socket.listen(128) while True: new_socket,client_add = tcp_socket.accept() service_client(new_socket) tcp_socket.close() if __name__ == ‘__main__‘: main()
标签:实现 new add web服务器 list imp == rom import
原文地址:https://www.cnblogs.com/xlcm/p/11348768.html