Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. ****
  2. ****
  3. ****
  4. ****
  5.  
  6. import re
  7. with open ('file1.txt') as fil1:
  8. for line in fil1:
  9. re.sub('^*{3}[*]*','**',line)
  10.  
  11. import fileinput
  12.  
  13. with fileinput.FileInput('file1.txt', inplace=True) as fil1:
  14. for line in fil1:
  15. print(re.sub('^*{3}[*]*','**', line.rstrip())) # inside the `with` clause, print writes to the file automatically
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement