Python Open

Asked 2 years ago, Updated 2 years ago, 17 views

If I want to read the text file a and save the resulting result as a text file b, can I use the open name twice in one code?

python

2022-09-22 19:11

2 Answers

You changed the question.

Of course, you have to use it once for reading and twice for writing.

r = open('', 'r')
line = r.readline(...)
...
...
w = open('', 'w')
w.write(line)


2022-09-22 19:11

https://wikidocs.net/26

The questioner's request is the same as giving a lecture on file with Python.

I'm thinking of recommending you a book, but there's a good document online, so it's a link.

Please learn the document of the link above and write down what you are curious about.


2022-09-22 19:11

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.