Skip to content

Instantly share code, notes, and snippets.

@hj91
Last active December 17, 2015 16:18
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 hj91/5637358 to your computer and use it in GitHub Desktop.
Save hj91/5637358 to your computer and use it in GitHub Desktop.
This gist is an example of opening a file in read only mode, reading its contents and manipulating some standard string functions.
a=open("text1.txt","r")
b=[]
for i in a.readlines():
b.append(i)
if b.__contains__("hello"):
print "Yes"
else:
print "No"
for j in b:
print b.strip("\n")
a.close()
hello
harshad
random
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment