【问题标题】:Python2.7 read csv file and read from the next linePython2.7读取csv文件并从下一行读取
【发布时间】:2017-11-27 06:10:04
【问题描述】:

我阅读了 csv 文件。然后我通过了空行。 当我发现一行不为空时,不要读取它并从下一行读取。 我怎样才能做到这一点? 这是我的代码。

f = open(self.row, 'r') #file open
for line in f.xrealines():
    if not line.strip() : #check if a line is empty or not
       continue
    else:
       #I want to skip one line and then adjust next line.
       row = line.strip('Wn').split(".')

【问题讨论】:

    标签: python-2.7 csv


    【解决方案1】:
    f = open(self.row, 'r') #file open
    for line in f.xreadlines():
        if not line.strip() : #check if a line is empty or not
           continue
        else:
           #I want to skip one line and then adjust next line.
           row = line.strip('Wn').split(".")
    

    现在检查!!! 你好像有错别字

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-06
      • 1970-01-01
      • 1970-01-01
      • 2020-01-12
      • 2020-12-19
      • 1970-01-01
      • 2014-12-10
      • 1970-01-01
      相关资源
      最近更新 更多