Linked Questions

187 questions linked to/from How do I append to a file?
59 votes
1 answer
180k views

with open("games.txt", "w") as text_file: print(driver.current_url) text_file.write(driver.current_url + "\n") I'm using this code right now, but when it writes to the file it overwrites the ...
user avatar
11 votes
1 answer
103k views

Usually to write a file, I would do the following: the_file = open("somefile.txt","wb") the_file.write("telperion") but for some reason, iPython (Jupyter) is NOT writing the files. It's pretty weird,...
12 votes
1 answer
33k views

How to check that the file exists? How to append a text to the file? I know how to create the file, but in this case, it overwrites all data: import io with open('text.txt', 'w', encoding='utf-8') ...
tomas's user avatar
  • 461
2 votes
4 answers
43k views

I have a file called output.txt, which I want to write into from a few functions around the code, some of which are recursive. Problem is, every time I write I need to open the file again and again ...
aviadm71's user avatar
5 votes
4 answers
20k views

I'm currently working on a bit of code that requires me to keep records of the outcome. However, at the minute, the code I'm using only overwrites the document, rather than adding on. What can I write ...
user3341402's user avatar
3 votes
2 answers
15k views

I'm new with Python and I know that piece of code is very simple and lacks some statements, actually I need to write to file from dictionary. This code runs but only writes the last item in dict to ...
2 votes
2 answers
8k views

I am trying to make a program that will take the answers of what the user inputted and put it in a text document in Python 2.7. I have the problem of when running the program again, the text document ...
5 votes
2 answers
5k views

I'm developing an application to write lines to a CSV. However, when I run the application a second time, the line that was already written is overwritten with the new line. How can I make it so that ...
1 vote
3 answers
9k views

I am new to programming and was wondering if anyone can help me. I have created a program below that enables me to write to the text file. I have a third Column called flower_quantity. I was wondering ...
2 votes
1 answer
5k views

I am trying to get the program to automatically start at the last line of a text file when I run it and make it write on the last line. My current code is as follows: with open('textfile.txt', 'a+') ...
BonsaiKaya's user avatar
-2 votes
3 answers
457 views

if data.find('!add') != -1: f = open('masters.txt', 'w') f.writelines(args, '\n') sck.send('PRIVMSG ' + chan + ' :' + ' added' + " " + args + '\r\n') f.close() When I use ...
SourD's user avatar
  • 2,899
4 votes
0 answers
6k views

I am trying to write a dictionary value to a YAML file. The dict is: data_dict = {'BACKENDTYPE' :{ 'BACKENDNAME' : 'BACKENDPATH'}} The update code is: with open(backend_config_file,'w')as yaml_file:...
0 votes
1 answer
3k views

I'm making what is supposed to be just a very basic OS during my free time. However, I'm trying to make it so that you can have as many users as you want, but every time I make a new user, it deletes ...
J. Bridges's user avatar
1 vote
1 answer
2k views

I am receiving data blocks from a server that sends out the data block as a string with the first 3 bytes representing the number of bytes of the data. The rest of the data are separated by tabs ...
-8 votes
1 answer
2k views

I coded a Python tool that calculates prime numbers within a given range. Then I decided that copying the numbers from the shell, creating a txt file, and pasting them every single time is a tad ...
Python_fan's user avatar

15 30 50 per page
1
2 3 4 5
...
13