Linked Questions

916 votes
9 answers
879k views

In Python's built-in open function, what is the difference between the modes w, a, w+, a+, and r+? The documentation implies that these all allow writing to the file, and says that they open the files ...
flybywire's user avatar
  • 276k
-3 votes
2 answers
497 views

I got nothing back from the command readline(). I am new to python and totally confused now. my_file = open("test.txt", "w+") my_file.write("This is a test") print my_file.readline()
S.Tan's user avatar
  • 1
1 vote
1 answer
126 views

I imagine this is a question asked already twenty thousand times, but I cannot understand why the file is always empty. I want to open a file, remove a string from the whole file and then rewrite the ...
LowFieldTheory's user avatar
0 votes
1 answer
122 views

The coding that I am using to learn: import requests r = requests.get("http://google.com") f = open("./page.html", "w+") f.write(r.text) So if i understand all right this will create a .html file ...
João Fróis's user avatar
1 vote
2 answers
91 views

Very short and simple. I am trying to create a highscore txt document for one of the games I'm making apart of a project. I want it to be able to keep the highest score ever reached in a text document ...
duck2205's user avatar
0 votes
1 answer
69 views

I am using VSC for writing python scripts to read/write file. I am able to write file using the below code: with open("score_card.txt", mode="w+") as file_data: file_data.write(...
Bilal Zafri's user avatar
0 votes
0 answers
52 views

def homeScreenArt(): print("-*----------*------------*------*------*-") print("-----*-------------*--------------*------") print("-----&&&&&--&&--&&----&...
Jack Carter's user avatar
0 votes
1 answer
60 views

I am trying to make a stock list display and editor project. I am trying to let users input what product they have and quantity they have in stock but it isnt saving to the txt file. Where am I going ...
SkiesLearns's user avatar
0 votes
1 answer
43 views

i tried to do unpickling using w+b mode. i got the exception EOFError: ran out of input. why is unpickling not possible in w+b mode? w+b mode also offers reading a binary file right then why am i ...
Aneesha Parti's user avatar
115 votes
6 answers
297k views

I have this code: line1 = [] line1.append("xyz ") line1.append("abc") line1.append("mno") file = open("File.txt","w") for i in range(3): file....
Sachin Patil's user avatar
  • 1,173
22 votes
6 answers
40k views

I noticed in the docs they always open a CSV file with ‘wb’. Why the ‘b’? I know b stands for binary mode, but when do you use binary mode (I’d guess CSV file is not binary). If relevant I’m writing ...
Celeritas's user avatar
  • 15.2k
7 votes
4 answers
28k views

I want to save pandas dataframe to csv in overwrite mode. I want that whenever the program will run again with any changes then it should save the dataframe to csv and overwrite the already saved csv ...
Mansi Arora's user avatar
0 votes
1 answer
9k views

So I'm trying to create a file and read from it even though its empty. So the next time I run the program the file will already exist and there will be data in it. #this should create the file ...
lun's user avatar
  • 45
6 votes
1 answer
18k views

I stumbled onto this stackoverflow question while doing some file IO: Confused by python file mode "w+" r for reading w for writing r+ opens for reading and writing (cannot truncate ...
Moon Cheesez's user avatar
  • 2,721
3 votes
4 answers
3k views

I want to download multiple specific links(images´ urls) into a txt file(or any file where all links can be listed underneath each others). I get them but the code wrtite each link on the top of the ...
TTT's user avatar
  • 33

15 30 50 per page
1
2 3 4 5