Skip to content

Instantly share code, notes, and snippets.

@harrifeng
Created May 4, 2013 12:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harrifeng/5517345 to your computer and use it in GitHub Desktop.
Save harrifeng/5517345 to your computer and use it in GitHub Desktop.
def print_file(path = "test.txt"):
"""print every word in the file
Arguments:
- `path`: file name
"""
mapped = dict()
with open(path, 'r') as f:
for line in f:
# print line.rstrip('\r\n')
for word in [x for x in line.rstrip('\r\n').split(' ') if len(x) > 0]:
print word
if __name__ == '__main__':
print_file('test.txt')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment