Write to a File Python

Writing to a file is very very simple in Python.

Simply open the file using open.

Write the contents to file and close it.

”’
Created on Jan 8, 2017
File Handling

@author: asharda
”’
f=open(“foo1.txt”,”w”)
f.write(‘This is Ashish \n’)
print(“Name of the file is “,f.name)
f.close()

Advertisements

About qainterviews

Software Geek,QA Expert,Blogger
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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