Fixing the issue of garbled characters (Chinese characters) when opening the CSV export in Microsoft Excel.

This commit is contained in:
Jinx 2024-02-04 14:20:10 +08:00
parent fa4a881ae1
commit 12c77b4850

View file

@ -196,7 +196,7 @@ def list_of_dicts2csv(dict_to_convert):
writer = csv.writer(csv_file)
writer.writerows(csv_data)
csv_file.seek(0)
csv_file = BytesIO(csv_file.getvalue().encode("utf-8"))
csv_file = BytesIO(csv_file.getvalue().encode("utf-8-sig"))
return csv_file