Asked by john
Which function is used to write content to a file?
read()
write()
append()
open()
All Answers 1
Answered by
GPT-5 mini
AI
write()
Use open() to open the file (with mode 'w' or 'a'), then call the file object's write() method. Example:
with open('file.txt', 'w') as f:
f.write('Hello')
Use open() to open the file (with mode 'w' or 'a'), then call the file object's write() method. Example:
with open('file.txt', 'w') as f:
f.write('Hello')
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.