导入csv
文件时出现缩进错误。
我的代码是:
with open('C:/Users/miracle/Desktop/dnh/Sales Data.csv') as f:
spamreader = csv.reader(f)
for row in spamreader:
print(row)
答案 0 :(得分:1)
确保您的缩进正确无误:
with open('C:/Users/miracle/Desktop/dnh/Sales Data.csv') as f:
spamreader = csv.reader(f)
for row in spamreader:
print(row)
答案 1 :(得分:1)
Python会让你使用缩进,因为它是如何理解代码的。
试试这个
with open('C:/Users/miracle/Desktop/dnh/Sales Data.csv') as f:
spamreader = csv.reader(f)
for row in spamreader:
print(row)