Menu

python读取txt逐行读取

发布时间:2019-11-11 13:53:27作者:柯曾栎 韩宇 热度: 675 ℃

import os
#coding=utf-8
import sys
f1 = open('./nickname.txt',encoding='UTF-8')

f2 = open('./test.txt','a')

for line in f1:
    print(line)  # 对每一行进行操作即可
    f2.write('INSERT INTO ta_nicknames VALUES ("", "'+line+'");')	
    f2.write("\n")
print("ok")

http://micuer.com/index.php?m=index&a=read&id=387


米醋儿 micuer.com