Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- thekindlyone@deepthought:~$ cat<file.txt
- From: malcom@serenity.com
- zdfdsfsfsf
- From: anara@serenity.com
- dfdf
- thekindlyone@deepthought:~$ ipython
- Python 2.7.6 (default, Mar 22 2014, 22:59:56)
- Type "copyright", "credits" or "license" for more information.
- IPython 1.2.1 -- An enhanced Interactive Python.
- ? -> Introduction and overview of IPython's features.
- %quickref -> Quick reference.
- help -> Python's own help system.
- object? -> Details about 'object', use 'object??' for extra details.
- In [1]: %paste
- fname='file.txt'
- try:
- with open(fname) as f:
- for line in f:
- words=line.split()
- if len(words)>1 and words[0]=='From:':
- print words[1]
- except:
- print 'Error opening file'
- ## -- End pasted text --
- malcom@serenity.com
- anara@serenity.com
- In [2]:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement