python - UnicodeEncodeError:“ascii”编解码器无法对位置 25-32 中的字符进行编码:序数不在范围内(128)
问题描述
>>a=u' Test for Garbling issue \ufffd\u3000\u2605\ufffd\u3000\u30c6\u30b9\u30c8 1'
>>a.encode('us-ascii')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode characters in position 25-32: ordinal not in range(128)
>> print a.encode('utf-8')
Test for Garbling issue � ★� テスト 1
但预期的输出是:
Test for Garbling issue ① ★㈱ テスト 1
解决方案
推荐阅读
- delphi-7 - 如何在 Delphi 7 中使用 OnGetPassword 发送密码以建立 SSL 连接
- python - Pvlib-Python 日期时间错误“不能转换为日期时间”
- java - 在 Android SDK 29 中管理 WiFi 网络共享
- python - 用于分类的字符串操作
- ios - iPadOS 13.4 Ble 配对弹出窗口在没有读/写受保护特征的情况下触发
- mysql - "LOAD" 在此位置对于服务器版本无效..." // 错误代码:1064。您的 SQL 语法有错误
- dart - Don't explicitly initialize variables to null
- javascript - IPFS 问题:无法使用 ipfs.add(file) 上传文件
- ios - 添加 SearchController 会导致导航栏变黑
- flutter - 使用 google_maps_flutter 检查坐标是否在颤振中的多边形内