file = open(file_path, "r")
content = file.readlines()
file.close()
return content
def write_file(content, file_path="abc1.txt"):
file = open(file_path, "w")
file.writelines(content)
file.flush()
file.close()
if __name__ == "__main__":
content = read_file()
new_content = list()
for c in content:
c = c.strip()
new_content.append(c + str(int(c) - 1) + "\r\n")
write_file(new_content)
s="指定字符串"f=open("文本文件名")n=int(raw_input("输入输出的行数:"))line=f.readline()while line:if s in line:print linefor i in range(n):line=f.readline()if line:print lineelse:breakif not line:breakline=f.readline()欢迎分享,转载请注明来源:内存溢出
评论列表(0条)