f = open("test.txt","r")
lines = f.readlines() #读取全部内容 ,并以列表方式返回
for line in lines
print line
name_list = [1, 2, 3]
for i in tqdm(name_list):
f = open('D:/project/tm_caption/file_names.txt', 'a')
f.write(str(i) + '\n')
f.close()
参考:https://blog.csdn.net/weixin_42599499/article/details/109250486