1 txt 读写
A txt读
1 def rfile(): 2 f = open(‘**.txt‘,‘r‘,encoding=‘UTF-8‘) # 中文读加编码格式 3 word_list = list(f.readlines()) 4 for i in range(len(word_list)): 5 word_list[i] = word_list[i].strip() # 去掉读取的换行,空格 6 return word_list
B txt写
1 def wfile(word): 2 f = open(‘**.txt‘,‘w‘) 3 f.writelines(word) 4 f.close()
2 excel读写