0
我一直在阅读Python文档的CSV模块在这里:https://docs.python.org/2/library/csv.htmlPython CSV阅读器:没有获取线路功能?
而且我注意到,它并没有提到任何方式为读者对象返回它当前正在读取的行数,或迭代它目前在。这似乎是一个广泛需要的功能。所以,我想知道如何做到这一点:
reader = csv.DictReader(readFile)
for row in reader:
# do something
# now want to find the line number that row corresponds to
或者,如果这是不可能的,为什么是这样的情况。
http://stackoverflow.com/questions/522563/accessing-the-index-in-python-for-loops –