为什么我无法分割这个字符串?

时间:2017-03-06 04:27:51

标签: python-2.7

f = open('gauss2.txt', 'r')
def readMatrix(f):
    new = {'matrix':[], 'op':[]}
    line = f.readline()
    count = 0
    while line != 'END\n':
        if line == 'DATA\n' or line == 'OP\n':
            count += 1
        elif count == 1:
            lst = line.split()
            newlst = []
            for num in lst:
                newlst.append(float(num))
            new['matrix'].append(newlst)
        elif count == 2:
            new['op'].append((line.strip()).split())
        line = f.readline
    f.close()
    return new
print readMatrix(f)

为什么说'builtin_function_or_method'对象对于lst = line.split()的行没有属性'split'?

0 个答案:

没有答案