客户端服务器的问题

python监听器收到客户端的请求后,主动do_Post给客户端发一条请求,收到客户端的应答之后通过原请求给客户端返回去,怎么操作,哪位大神给知道一下

给原请求应答的代码

if not self.wfile.closed:
            self.send_response(200)
        if not self.wfile.closed:
            print (strs)
            self.send_header("Content-Length", str(len(strs)))
            self.end_headers()

            self.wfile.write(strs)


strs内容如下

<html><head></head><body><table style="border-collapse:collapse"><tr><td style="width:200px;border: 1px #000 solid;word-break:keep-all">出参:</td><td style="border: 1px #000 solid;word-break:keep-all">{RTN_CODE=0, RTN_MSG=BP节点号:[311],业务程序运行正常}</td></tr><tr><td style="border: 1px #000 solid;word-break:keep-all" colspan="2">网页签约异步处理结果如下:</td></tr><tr><td colspan="2"><table style="border-collapse:collapse"><tr><td style="border: 1px #000 solid;word-break:keep-all">第二结果集</td><td style="border: 1px #000 solid;word-break:keep-all">OCCUR_DATE</td><td style="border: 1px #000 solid;word-break:keep-all">TRD_BIZ_STATUS</td><td style="border: 1px #000 solid;word-break:keep-all">PY_ORG_CODE</td><td style="border: 1px #000 solid;word-break:keep-all">OCCUR_TIME</td><td style="border: 1px #000 solid;word-break:keep-all">SERIAL_NO</td><td style="border: 1px #000 solid;word-break:keep-all">PY_ACC</td></tr><tr><td style="border: 1px #000 solid;word-break:keep-all">1</td><td style="border: 1px #000 solid;word-break:keep-all">20180602</td><td style="border: 1px #000 solid;word-break:keep-all">9</td><td style="border: 1px #000 solid;word-break:keep-all">7</td><td style="border: 1px #000 solid;word-break:keep-all">20454058</td><td style="border: 1px #000 solid;word-break:keep-all">201806020000000033</td><td style="border: 1px #000 solid;word-break:keep-all"></td></tr></table></td></tr></table></body>

报错如下



----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 18521)
Traceback (most recent call last):
  File "D:\Install\Python27\lib\SocketServer.py", line 284, in _handle_request_noblock
    self.process_request(request, client_address)
  File "D:\Install\Python27\lib\SocketServer.py", line 310, in process_request
    self.finish_request(request, client_address)
  File "D:\Install\Python27\lib\SocketServer.py", line 323, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "D:\Install\Python27\lib\SocketServer.py", line 639, in __init__
    self.handle()
  File "D:\Install\Python27\lib\BaseHTTPServer.py", line 343, in handle
    self.handle_one_request()
  File "D:\Install\Python27\lib\BaseHTTPServer.py", line 331, in handle_one_request
    method()
  File "D:\javaProject\hftx\httpserver2_hftx.py", line 47, in do_POST
    self.wfile.write(strs)
  File "D:\Install\Python27\lib\socket.py", line 316, in write
    data = str(data) # XXX Should really reject non-string non-buffers
UnicodeEncodeError: 'ascii' codec can't encode characters in position 136-137: ordinal not in range(128)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值