python报错:AttributeError: 'numpy.ndarray' object has no attribute 'write'

源代码如下
with open('表示.txt','a',encoding='utf-8') as f:
        with open('a-0.txt','r',encoding='utf-8')as f0:
            a=eval(f0.read())
            for keys in a.keys():
                s = 0.0
                for word in a[keys].keys():
                    try:
                        k,f=search(word)
                    except KeyError:continue
                    for kk in k:
                        s+=kk*a[keys][word]
                try:
                    s =s.tolist()
                except:continue
                print(type(s))
                out=str(keys)+'/t0/t'+str(s)
                f.write(str(out))
本意是把列表里的数取出并累加,然后求得一个和,但是在write处报了AttributeError;

后来以为是变量s的类型是np.nd的原因,但是在改变s的类型之后f.write()函数仍然报同样的错。
发现不只是写入s报错,在写入文件f.write(str(keys))也会报同样的问题。
不知道是不是循环的原因?

求指教