Advertisement
Guest User

Untitled

a guest
May 2nd, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.33 KB | None | 0 0
  1. lines = open('/etc/hosts').read().split('\n')
  2.  
  3. for line in lines:
  4.     if "localhost" in line:
  5.         localhost_IsOnLineNumber = lines.index(line)
  6.         print (localhost_IsOnLineNumber)
  7.         lines.insert (localhost_IsOnLineNumber + 1, '#this is a comment after localhost')
  8.  
  9. #see if it worked
  10. for line in lines:
  11.     print line
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement