读取csv文件时出现语法错误。我知道这对你们大多数人来说可能很愚蠢。但是现在对我来说这是最重要的。实际上,我遇到了Unicode错误,在此之前我以'r'克服了前缀。现在,它显示出语法错误。
train = pd.read_csv(r 'C:\Users\Siddhu\Downloads\train-images-idx3-ubyte.csv')
test = pd.read_csv(r 'C:\Users\Siddhu\Downloads\t10k-images-idx3-ubyte.csv')
File "<ipython-input-23-2341446e2439>", line 1
train = pd.read_csv(r 'C:\Users\Siddhu\Downloads\train-images-idx3-ubyte.csv')
^
SyntaxError: invalid syntax
答案 0 :(得分:3)
r和文件路径之间的空格:
train = pd.read_csv(r 'C:\Users\Siddhu\Downloads\train-images-idx3-ubyte.csv')
^
到
train = pd.read_csv(r'C:\Users\Siddhu\Downloads\train-images-idx3-ubyte.csv')
如果删除空格,它将正常工作!