W
W
Wynell_ru2020-03-15 15:01:06
Python
Wynell_ru, 2020-03-15 15:01:06

How to force to be written to the csv file right after opening?

Here is the code:

import csv
file = open("kek.csv", "w+")
writer = csv.writer(file)
writer.writerow(["1", "22", "333"])

Operating system - MacOS High Sierra (well, it can affect)
If the file exists, then the line 1,22,333 is written
But if it does not exist, then it is only created, and nothing is written to it

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2020-03-15
@bacon

You were told about close in the last question. And it's better with open
And stop being a woodpecker, it's written about in the docks and google without any problems.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question