NoneType对象没有属性计数

时间:2019-03-17 20:10:56

标签: string list

我对此有疑问 它一直在说:NoneType对象没有属性计数

def failListiks(failinimi):
    with open(failinimi) as f:   
        listina = f.readlines()
        print(listina)
    return

minulist = failListiks("sonad.txt")
tahtedearv = minulist.count("a")
print(tahtedearv)

1 个答案:

答案 0 :(得分:0)

failListiks返回None。我怀疑您想返回行列表,但是您只是在打印它们。进行以下更改:

def failListiks(failinimi):
    with open(failinimi) as f:   
        listina = f.readlines()
        print(listina)
        return listina # return the lines