Answers for "python from file"

18

open text file in python

f=open("Diabetes.txt",'r')
f.read()
Posted by: Guest on April-25-2020
11

python file open

#there are many modes you can open files in. r means read.
file = open('C:\Users\yourname\files\file.txt','r')
text = file.read()

#you can write a string to it, too!
file = open('C:\Users\yourname\files\file.txt','w')
file.write('This is a typical string')

#don't forget to close it afterwards!
file.close()
Posted by: Guest on March-26-2020

Python Answers by Framework

Browse Popular Code Answers by Language