UnicodeEncodeError:'ascii'编解码器无法在位置1985处编码字符'\\ u2013':序数不在range(128)python3中

时间:2019-12-17 09:58:43

标签: python-3.x

我在python 3烧瓶中有一个api以发送电子邮件。 下面是它的json正文。

{\\'sender\\': \\'alerts@mswipemail.com\\', \\'receiver\\': \\'pgiri388@gmail.com\\', \\'subject\\': \\'SOA Payment Details with CSV\\', \\'header\\': \\'\\', \\'notification_type\\': \\'email\\', \\'request_service\\': \\'PPS\\', \\'body\\': \\'<!DOCTYPE html><html><head><meta charset=utf - 8 /><style type = text/css>#testColor td.red {color: crimson;}#testColor td.Sign {color: #1F497D;}.custom {font-family: Calibri;}</style></head><body><table border = 0 cellpadding = 0 cellspacing = 0 height = 500 width=100% id=testColor class =custom> <tr height=20><td>Dear DRESS POINT ,<br /><br /></td></tr><tr height=20><td>Thank you for choosing to receive statement via email.<br /><br /></td></tr><tr height=20><td>Please find attached the e-statement for your Customer Code 9400059207 for the date 16-Dec-2019 .<br /><br /></td></tr><tr height=20><td><br /><br /></td></tr><tr height=20><td class=Sign>Regard\\\\\\'s,<br /></td></tr><tr height=20><td class=Sign>Mswipe Technologies Pvt. Ltd.</td></tr><tr height=20><td><img src="https://mswipe-notify-img.s3.ap-south-1.amazonaws.com/mSwipeLogo2.png" alt=logo /></td></tr><tr height=20><td class=Sign><b>Mswipe Technologies Pvt. Ltd.</b></td></tr><tr height=20><td class=Sign>Unit No A \xe2\x80\x93 2602, 26th Floor, Marathon Futurex, Mafatlal Mills Compound,</td></tr><tr height=20><td class=Sign>N.M. Joshi Marg, Lower Parel, Maharashtra, Mumbai - 400 013</td></tr><tr height=20><td class=Sign>Phone: +91 22 4922 4466 (board) | Helpdesk: 1800 1022 699 | </td></tr><tr height=20><td class=Sign>Web: <a href=https://www.mswipe.com/ >www.mswipe.com</a></td></tr></table></body></html>\\'}

下面是错误。

Arguments: ()
[Mon Dec 16 07:13:44.725199 2019] [wsgi:error] [pid 3833:tid 140380787955456] [client 172.31.21.89:5038] --- Logging error ---
[Mon Dec 16 07:13:44.725317 2019] [wsgi:error] [pid 3833:tid 140380787955456] [client 172.31.21.89:5038] Traceback (most recent call last):
[Mon Dec 16 07:13:44.725341 2019] [wsgi:error] [pid 3833:tid 140380787955456] [client 172.31.21.89:5038]   File "/usr/lib/python3.6/logging/__init__.py", line 996, in emit
[Mon Dec 16 07:13:44.725360 2019] [wsgi:error] [pid 3833:tid 140380787955456] [client 172.31.21.89:5038]     stream.write(msg)
[Mon Dec 16 07:13:44.725378 2019] [wsgi:error] [pid 3833:tid 140380787955456] [client 172.31.21.89:5038] UnicodeEncodeError: 'ascii' codec can't encode character '\\u2013' in position 1985: ordinal not in range(128)
[Mon Dec 16 07:13:44.725389 2019] [wsgi:error] [pid 3833:tid 140380787955456] [client 172.31.21.89:5038] Call stack:
[Mon Dec 16 07:13:44.725500 2019] [wsgi:error] [pid 3833:tid 140380787955456] [client 172.31.21.89:5038]   File "/srv/pythonenvs/mswipe-notify/lib/python3.6/site-packages/flask/app.py", line 2309, in __call__
[Mon Dec 16 07:13:44.725508 2019] [wsgi:error] [pid 3833:tid 140380787955456] [client 172.31.21.89:5038]     return self.wsgi_app(environ, start_response)
[Mon Dec 16 07:13:44.725516 2019] [wsgi:error] [pid 3833:tid 140380787955456] [client 172.31.21.89:5038]   File "/srv/pythonenvs/mswipe-notify/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app
[Mon Dec 16 07:13:44.725521 2019] [wsgi:error] [pid 3833:tid 140380787955456] [client 172.31.21.89:5038]     response = self.full_dispatch_request()
[Mon Dec 16 07:13:44.725528 2019] [wsgi:error] [pid 3833:tid 140380787955456] [client 172.31.21.89:5038]   File "/srv/pythonenvs/mswipe-notify/lib/python3.6/site-packages/flask/app.py", line 1811, in full_dispatch_request
[Mon Dec 16 07:13:44.725533 2019] [wsgi:error] [pid 3833:tid 140380787955456] [client 172.31.21.89:5038]     rv = self.preprocess_request()
[Mon Dec 16 07:13:44.725540 2019] [wsgi:error] [pid 3833:tid 140380787955456] [client 172.31.21.89:5038]   File "/srv/pythonenvs/mswipe-notify/lib/python3.6/site-packages/flask/app.py", line 2087, in preprocess_request
[Mon Dec 16 07:13:44.725544 2019] [wsgi:error] [pid 3833:tid 140380787955456] [client 172.31.21.89:5038]     rv = func()
[Mon Dec 16 07:13:44.725551 2019] [wsgi:error] [pid 3833:tid 140380787955456] [client 172.31.21.89:5038]   File "/srv/mswipe-notify/app/handlers/base_handler.py", line 22, in before_request_middleware
[Mon Dec 16 07:13:44.725555 2019] [wsgi:error] [pid 3833:tid 140380787955456] [client 172.31.21.89:5038]     request.get_json()))
[Mon Dec 16 07:13:44.725588 2019] [wsgi:error] [pid 3833:tid 140380787955456] [client 172.31.21.89:5038] Message: 'Request for handler /api/notification is <Request \\'http://notify.mswipe.com/mswipe-notify/api/notification\\' [POST]> having headers - X-Forwarded-For: 59.144.227.106\\r\\nX-Forwarded-Proto: http\\r\\nX-Forwarded-Port: 80\\r\\nHost: notify.mswipe.com\\r\\nX-Amzn-Trace-Id: Root=1-5df72ea8-b77efe12c0abccfc5ecc55b8\\r\\nContent-Length: 4165\\r\\nX-Newrelic-Id: VQEGVlJbDxAEVlFaBAQEVVw=\\r\\nX-Newrelic-Transaction: PxQAJSVWCwAGVSIgdQlxXicIFB8EBw8RVU4aVXx7AQEAUwgicyMLJFx1DkNKQV0KBlcHAAFQFTs=\\r\\nAccept: application/json\\r\\nContent-Type: multipart/form-data; boundary="8a868931-1bc6-4133-a7d0-e6c54608617c"\\r\\nAuthorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzZXJ2aWNlX25hbWUiOiJQUFMifQ.n3Y7u4vgphAb4t6DG9AZNizt-XATeBErv46hdN3MK3E\\r\\n\\r\\n with arguments/body {} {\\'sender\\': \\'alerts@mswipemail.com\\', \\'receiver\\': \\'pgiri388@gmail.com\\', \\'subject\\': \\'SOA Payment Details with CSV\\', \\'header\\': \\'\\', \\'notification_type\\': \\'email\\', \\'request_service\\': \\'PPS\\', \\'body\\': \\'<!DOCTYPE html><html><head><meta charset=utf - 8 /><style type = text/css>#testColor td.red {color: crimson;}#testColor td.Sign {color: #1F497D;}.custom {font-family: Calibri;}</style></head><body><table border = 0 cellpadding = 0 cellspacing = 0 height = 500 width=100% id=testColor class =custom> <tr height=20><td>Dear DRESS POINT ,<br /><br /></td></tr><tr height=20><td>Thank you for choosing to receive statement via email.<br /><br /></td></tr><tr height=20><td>Please find attached the e-statement for your Customer Code 9400059207 for the date 16-Dec-2019 .<br /><br /></td></tr><tr height=20><td><br /><br /></td></tr><tr height=20><td class=Sign>Regard\\\\\\'s,<br /></td></tr><tr height=20><td class=Sign>Mswipe Technologies Pvt. Ltd.</td></tr><tr height=20><td><img src="https://mswipe-notify-img.s3.ap-south-1.amazonaws.com/mSwipeLogo2.png" alt=logo /></td></tr><tr height=20><td class=Sign><b>Mswipe Technologies Pvt. Ltd.</b></td></tr><tr height=20><td class=Sign>Unit No A \xe2\x80\x93 2602, 26th Floor, Marathon Futurex, Mafatlal Mills Compound,</td></tr><tr height=20><td class=Sign>N.M. Joshi Marg, Lower Parel, Maharashtra, Mumbai - 400 013</td></tr><tr height=20><td class=Sign>Phone: +91 22 4922 4466 (board) | Helpdesk: 1800 1022 699 | </td></tr><tr height=20><td class=Sign>Web: <a href=https://www.mswipe.com/ >www.mswipe.com</a></td></tr></table></body></html>\\'} None'

我尝试寻找它,但是,我得到了python 2,但没有得到python 3

0 个答案:

没有答案