About 892,000 results
Open links in new tab
  1. python - Correct way to write line to file? - Stack Overflow

    May 28, 2011 · So this is the way I usually do it Statement from docs.python.org: It is good practice to use the 'with' keyword when dealing with file objects. This has the advantage that …

  2. python - How do I write JSON data to a file? - Stack Overflow

    3339 data is a Python dictionary. It needs to be encoded as JSON before writing. Use this for maximum compatibility (Python 2 and 3):

  3. file - .write not working in Python - Stack Overflow

    Files are closed when Python exists, but file output is usually buffered and if there is no newline, pending output will not be flushed to the file system.

  4. python logging module is not writing anything to file

    python logging module is not writing anything to file Asked 12 years, 9 months ago Modified 2 years, 9 months ago Viewed 101k times

  5. python - How to write a list of numbers as bytes to a binary file ...

    With Python 2 on Windows, I found that writing a bytearray still converts \n to \r\n, making it unsatisfactory for binary data, if the "b" flag is not passed when opening the file.

  6. Python multiprocessing safely writing to a file - Stack Overflow

    Nov 19, 2012 · 5 In response to the comments saying that this is being run on a cluster, a simple option, which doesn't rely on inter-process communication, is to lock the memoization file …

  7. python - Writing Unicode text to a text file? - Stack Overflow

    May 18, 2011 · The file opened by codecs.open is a file that takes unicode data, encodes it in iso-8859-1 and writes it to the file. However, what you try to write isn't unicode; you take unicode …

  8. python - How to replace/overwrite file contents instead of …

    When you say "replace the old content that's in the file with the new content", you need to read in and transform the current contents data = file.read(). You don't mean "blindly overwrite it …

  9. file - Python writing binary - Stack Overflow

    I use python 3 I tried to write binary to file I use r+b. for bit in binary: fileout.write(bit) where binary is a list that contain numbers. How do I write this to file in binary? The end fil...

  10. Writing string to a file on a new line every time - Stack Overflow

    May 27, 2010 · I want to append a newline to my string every time I call file.write(). What's the easiest way to do this in Python?