【发布时间】:2017-01-17 12:31:30
【问题描述】:
我需要在bash中解析一些简单的JOSN,其中包含没有外部依赖的非ascii字符,所以我使用了python解决方案from this answer
cat $JSON_FILE | python -c "import sys, json; print json.load(sys.stdin)['$KEY']"
这适用于 ascii 值,但其他值会引发此错误:
'ascii' 编解码器无法对位置 1212 中的字符 u'\u2019' 进行编码:序数不在范围内(128)
看着this answer,我想我需要转换为unicode 类型,但我不知道如何。
【问题讨论】:
标签: python json bash python-2.x