I want to run this code block :
>>> json1 = json.loads("""[{"categoryId":"32","nameAr":"\u0627\u0643\u0644 \u0633\u0631\u064a\u0639","nameEn":"Fast Food"}]""")
>>> file1 = open("test.csv","w")
>>> fieldnames = json1[0].keys()
>>> writer = csv.DictWriter(file1, fieldnames=fieldnames)
>>> writer.writeheader()
>>> writer.writerow(json1[0])
but I get this error :'ascii' codec can't encode characters in position 0-2, I think this happened because I should encode json1 values to utf-8 , How could I do that ?