<Apti
Code
/>
Back
Question 484: How can you read the entire contents of a file named "data.txt" into a string?
tcs
wipro
infosys
general
aptitude
reading-and-writing-files
python-programming
Using theread()method on the file object reads the entire contents of the file into a string.
content = read_file("data.txt")
content = open("data.txt").read()
content = file.read("data.txt")
content = open_file("data.txt", "r")
Submit Answer
Show Answer
Previous
Next