不会让我在Python 3中打开csv文件 [英] Won't let me open csv file in Python 3
本文介绍了不会让我在Python 3中打开csv文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在python 3中打开一个csv文件,当我这样做时(Unicode错误)'unicodeescape'编解码器无法解码位置2-3的字节:截断/ UXXXXXXXX转义
它突出显示(打开/之后'C:\ Users \ Me\Desktop\csv file.csv'
我不知道错误是什么,因为我不知道Unicode错误是什么意思
这是代码:
import csv
打开(' C:\Users\Me\Desktop\csv file.csv' ) as csvfile:
y = csv.reader(csvfile,delimiter = ' ,')
Names = []
Ages = []
for y中的span> x :
print (行[ 0 ],行[ 1 ])
我的尝试:
我想不出任何可以尝试的东西
解决方案
参见 7.2。编解码器 - 编解码器注册表和基类 - Python 3.6.4文档 [ ^ ]。
I am trying to open a csv file in python 3 and when ever I do it says (Unicode error)'unicodeescape' codec can't decode bytes in position 2-3: truncated /UXXXXXXXX escape
It highlights the ( after open/ before 'C:\Users\Me\Desktop\csv file.csv'
I'm not sure what the error is since I don't know what it meant with the Unicode error
This is the code:
import csv
with open('C:\Users\Me\Desktop\csv file.csv') as csvfile:
y = csv.reader(csvfile, delimiter=',')
Names = []
Ages = []
for x in y:
print(row[0], row[1])
What I have tried:
I can't think of anything to try
解决方案
See 7.2. codecs — Codec registry and base classes — Python 3.6.4 documentation[^].
这篇关于不会让我在Python 3中打开csv文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文