Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- lines = open('/etc/hosts').read().split('\n')
- for line in lines:
- if "localhost" in line:
- localhost_IsOnLineNumber = lines.index(line)
- print (localhost_IsOnLineNumber)
- lines.insert (localhost_IsOnLineNumber + 1, '#this is a comment after localhost')
- #see if it worked
- for line in lines:
- print line
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement