Python:文件中每行开头加一个逗号‘,’

来源:互联网 发布:韩信守荆州 知乎 编辑:程序博客网 时间:2024/06/05 11:26
From_file=open('D:\\python\\A\\tianqi.txt')f=open('niuniu1.txt','w')count=0for each_line in From_file:    f.writelines(','+each_line)    count+=1f.close()From_file.close()print('文件中总共有:%d行'%count)