gpt4 book ai didi

python - typeerror '_csv.reader' 对象不可订阅

转载 作者:太空狗 更新时间:2023-10-30 01:08:31 25 4
gpt4 key购买 nike

<分区>

当我尝试在 python 中打开文件时出现错误,typeerror '_csv.reader' object is not subscriptable。代码如下,请哪位好心人帮帮我

with open(file) as f:  
reader = csv.reader(f, delimiter='\t')
for line in reader:
oldseq, city, state, newseq = line

错误在这里,在下面的代码中,for line in reader[:1]:

with open(newfile) as f:  
reader = csv.reader(f, delimiter='\t')
for line in reader[:1]:
oldseq, city, state, newseq = line

我只需要跳过第一行,因为它有标题,这就是我使用 reader[:1] 的原因

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