gpt4 book ai didi

python - 读取 CSV 文件时出现奇怪的字符

转载 作者:行者123 更新时间:2023-12-05 08:14:24 29 4
gpt4 key购买 nike

我尝试用 Python 读取 CSV 文件,但第一行的第一个元素是这样读取的 0,而奇怪的字符不在文件中,它只是一个简单的 0。这是我使用的代码:

matriceDist=[]
file=csv.reader(open("distanceComm.csv","r"),delimiter=";")
for row in file:
matriceDist.append(row)
print (matriceDist)

最佳答案

我遇到了同样的问题。将您的 excel 文件保存为 CSV (MS-DOS) 与 UTF-8 相比,那些奇怪的字符应该会消失。

关于python - 读取 CSV 文件时出现奇怪的字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50228008/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com