Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否可以在 python 上仅加载一行 csv 文件?我有一个巨大的 csv 文件,我只想复制它的标题。我可以以一种内存有效的方式做到这一点吗?
next()在阅读器对象上使用。
next()
headerrow = next(reader)
使用next:
next
with open('your_file.csv') as f: reader = csv.reader(f) header = next(reader)