file = open(‘face.txt‘,‘r‘) filew = open(‘face1.txt‘,‘w‘) try: for line in file: print(line) if line.strip() !=‘‘: line = ‘"‘+line.strip()+‘"‘+",\n" // 去掉空格、换行符 加上引号 逗号 换行符 filew.write(line) finally: file.close() filew.close()
时间: 2024-10-13 16:21:20