其它常用

1.导出列表

def totxt(resultname,L):
    f=open(resultname,"w")
        
    for name in L:
        f.write(str(name)+'\n')  
    f.close()

2.读入列表

def txttolist(file_path):
    fi=open(file_path,'r')
    txt=fi.readlines()
    L = []
    for w in txt:
        w=w.replace('\n','')
        L.append(int(w))
    return L
posted @ 2021-11-15 22:33  skypanxh  阅读(20)  评论(0)    收藏  举报