Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 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. text = re.sub('^*{3}[*]*','**', line.rstrip()).strip()
  16. if text:
  17. print(text) # inside the `with` clause, print writes to the file automatically
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement