Python - File Reading and Writing Strategies
What is wrong with this code snippet that tries to read the entire file content?
file = open('data.txt')
content = file.read
print(content)file = open('data.txt')
content = file.read
print(content)file.read without parentheses, so it assigns the method itself, not the result of reading.content prints a method object reference, not file text, causing confusion.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions