PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, May 13, 2022

[FIXED] How do you append to a file?

 May 13, 2022     append, file, python     No comments   

Issue

How do you append to the file instead of overwriting it? Is there a special function that appends to the file?


Solution

This can be achieved by setting the mode in open() to "a" (append) instead of "w" (write). See the documentation op open() for all available modes.

with open("test.txt", "a") as myfile:
    myfile.write("appended text")


Answered By - Petter
Answer Checked By - Gilberto Lyons (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing