无法使用 csv 从 Excel 读取本地语言数据

问题描述 投票:0回答:1

我在 CSV 文件中以“यह एक नमूना संदेश है”形式提供数据。我正在使用 python 中的 CSV 模块读取文件内的数据。 示例代码:

  csvFile = request.FILES.get('file')
  csv_copy = copy.deepcopy(csvFile)
  file_content = csv_copy.read()
  decoded_file = file_content.decode('utf-8').splitlines()
  reader = csv.reader(decoded_file)
  rows = list(reader)
  for i,row in enumerate(rows):
      print(row[1])

给定的数据被转换为“????????????” 有什么办法可以解决这个问题吗?

python django csv python-3.8
1个回答
0
投票

可以使用 CSV UTF-8(.csv) 格式保存 CSV 文件。感谢您的回复。

© www.soinside.com 2019 - 2024. All rights reserved.