import osos.mkdir("D:\\1815925603")context = ("序号:1815925603\n""姓名:阿信\n""班级:18云计算2班\n")with open ('D:\\1815925603\\file1.txt','a+') as fp:fp.write(context)fp.seek(0, 0)with open ('D:\\1815925603\\file1.txt','r') as fp:data=fp.readlines()print(data)fp.close() try:os.rename('D:\\1815925603\\file1.txt','D:\\1815925603\\file2.txt')except Exception as e:print(e)print('rename file fail\r\n')else:print('rename file success\r\n')os.remove(r'D:\\1815925603\\file2.txt')
1200字范文,内容丰富有趣,写作的好帮手!