Answers for "python file methods"

11

python file open

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

#you can write a string to it, too!
file = open('C:Usersyournamefilesfile.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
7

python file reading

fin = open("NAME.txt", 'r')
body = fin.read().split("n")
line = fin.readline().strip()
Posted by: Guest on May-06-2020
0

python file

>>> f = open('workfile', 'w')
Posted by: Guest on July-24-2021
0

file methods in python

file = open(filename, filemode)
file.readable()
file.writable()
file.read()
file.readlines()
file.seek()
file.tell()
file.write()
file.close()
Posted by: Guest on September-28-2021
-3

python file a?

print("ddd")
Posted by: Guest on July-17-2021

Python Answers by Framework

Browse Popular Code Answers by Language