Posted by: Sourav | March 26, 2017

Basic write operation on text files in python 2.7,Python teacher Sourav,Kolkata 09748184075

print(“Creating a text file with the write() method.”)
text_file = open(“write_it.txt”, “w”)
text_file.write(“Line 1\n”)
text_file.write(“This is line 2\n”)
text_file.write(“That makes this line 3\n”)


print(“\nReading the newly created file.”)
text_file = open(“write_it.txt”, “r”)


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: