What's the exact syntax of Python I/O file?

Recommended Posts

Can anyone tell me is it right syntax?

For Open:

f = open("file name", file_mode) f is file object

f = open("file.txt", w)

For Close:

f = open("file.txt",'w')

f.close() # close a file

If it does not then tell me the exact syntax of how to create it. I just see this same syntax to the other side here but when I coded it's not working. 

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.