How to write a whole string to a file in Python and where does the file go? -


I am making an assignment on text formatting and alignment (wrapping text) and I have to type my formatted string in a new file . But once I have written the file (or think I have written) where does that file go? Is it really making a file on my desktop or am I stupid?

This is my code:

  txtFile = open ("Output.txt", "w") TxtFile.write (string) txtFile.close () return txtFile < / Code>  

Cheers,

jt

your In the working directory, a text is written in a file named "output.txt" (which is usually the directory in which the script is executed).

To display the work directory, you can use it:

  & gt; & Gt; & Gt; Import OS & gt; & Gt; & Gt; Os.getcwd () '/ home / adam'    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -