如何输出`micro`字符python json.dumps

时间:2018-06-23 23:03:38

标签: python json unicode python-unicode

我不确定问题的具体术语,所以让我描述一下确切的问题本身:

test.csv

foo,char
"bar","µ"

test.py

#!/usr/bin/env python3

import csv
import json

with open('test.csv', mode='r') as file:
    reader = csv.DictReader(file)
    for row in reader:
        print(json.dumps(row))

预期输出:

{"foo": "bar", "char": "µ"}

实际输出:

{"foo": "bar", "char": "\u00b5"}

我尝试将encoding='utf-8'添加到open(),但不会更改输出。

0 个答案:

没有答案