我想将1500行的文件分隔成元数据和数据。else和elif的语法错误
以下是我有:
headerLines = []
dataLines = []
for line in lineList:
if (len(line) > 0 and (line[0] == #)) :
headerLines.append(line)
elif (len(line) > 0 and (line[0] == U):
dataLines.append(line)
print("we have {} lines of metadata".format(len(headerLines)))
print("we have {} lines of data".format(len(dataLines)))
#here we want to seperate the lines in the file into headerLines and dataLines
你能解释一下你得到的错误吗? –
教授给出了前三行和最后两行,我们只需填写“if”语句,我还在“elif”中添加了缺少的括号,它没有改变任何事情,它只是说句法错误无效,有点胡萝卜指向elif。 –
似乎它是'#',它是用来评论python中的一行的特殊字符.Hash符号后面的所有内容都被认为已被删除。 –