9951 explained code solutions for 126 technologies


pythonHow to read text file


with open('/tmp/file.txt', 'r') as f:
  data = f.read()ctrl + c
with open(

opens file with the specified mode

/tmp/file.txt

path to the file we want to read

'r'

read mode

read()

read all text from a file into a string