T
T
TRXTSSA2021-11-17 21:03:38
Python
TRXTSSA, 2021-11-17 21:03:38

Why doesn't file.read() work the way I want it to?

I have a file status.txtthat contains only one word, for example nothing
Question: why does it open('status.txt', 'w+').read() == 'nothing'return false? And how to fix it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
LXSTVAYNE, 2021-11-17
@TRXTSSA

You are opening the file for writing, not for reading. You need to do something like this:
open('status.txt', 'r').read() == 'nothing'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question