yazdmich

Untitled

Nov 13th, 2015
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. import os, time
  2. test = []
  3. os.chdir('C:\\Users\\Michael\\mIRC')
  4. with open('mirc.ini', 'r') as f:
  5. for line in f:
  6. if line.startswith('lastrun'):
  7. test.append('lastrun=\r\n')
  8. else:
  9. test.append(line)
  10. print('File modified')
  11. with open('mirc-new.ini', 'w') as f:
  12. for line in test:
  13. f.write(line)
  14. print('file written')
  15. os.rename('mirc.ini', 'mirc-{}.ini'.format(int(time.time())))
  16. print('old file preserved and renamed')
  17. os.rename('mirc-new.ini', 'mirc.ini')
  18. print('new file in place')
Advertisement
Add Comment
Please, Sign In to add comment