标签:line sig 文件操作 bsp split code end 期望 adl
mr mr
ms ms
ex ex
mr mr Lock
ms ms
ex ex
user_write=[]
user_read=open("user_msg.txt","r")
for line in user_read.readlines():
sign_user_line=line.strip().split("\t")
if sign_user == sign_user_line[0]:
line=line.strip()+"\tLock"
user_write.append(line)
user_read.close()
user_write_file=open("user_msg.txt","w")
for i in range(0,len(user_write)):
user_write_file.writelines(user_write[i])
user_write_file.close()
写完以后文件却变成了
mr mr
Lock ms ms
ex ex
user_write=[]
user_read=open("user_msg.txt","r")
for line in user_read.readlines():
sign_user_line=line.strip().split("\t")
if sign_user == sign_user_line[0]:
line=line.strip("\n")+"\tLock\n"
user_write.append(line)
user_read.close()
user_write_file=open("user_msg.txt","w")
for i in range(0,len(user_write)):
user_write_file.writelines(user_write[i])
user_write_file.close()
标签:line sig 文件操作 bsp split code end 期望 adl
原文地址:http://www.cnblogs.com/mstzkot/p/7189551.html