Kam*_*mal 2 python unicode simplejson
这是使用python2.4版本的简单json示例运行
>>>
>>> orig='{"key1":"Val", "key2":"val2"}'
>>> origDict = simplejson.loads(orig)
>>> origDict
{'key2': 'val2', 'key1': 'Val'}
>>> origDict['key2'] = '\xe4\xbd\xa0\xe5\xa5\xbd'
>>> simplejson.dumps(origDict)
'{"key2": "\\u4f60\\u597d", "key1": "Val"}'
Run Code Online (Sandbox Code Playgroud)
dumps函数正在用unicode版本替换字节字符串.有没有办法让它不这样做,只返回'{"key2":"\ xe4\xbd\xa0\xe5\xa5\xbd","key1":"Val"}'?
| 归档时间: |
|
| 查看次数: |
6372 次 |
| 最近记录: |