python写入文件

import sys
import os
f=open('d:/jpg_name.txt','w')
name=[]
jpg=[]
jpg1=[]
jpg_name=[]

for line in open('d:/py_code/darknet-7_20180720.txt'):
    #print(line,end='')
    name.append(line)
for i in range(466284):
    if i %2 ==0:
        jpg.append(name[i][-6:-1])
        jpg1.append(name[i][-25:-21])
        #print(name[i][0:66])
        jpg_name.append(name[i][66:124])
        #print(name[i][66:124])
        f.writelines(str(name[i][66:124])+'\n')
        #f.writelines(+'\n')
        #f.close() 

把数组写入txt文件中

你可能感兴趣的:(python写入文件)