In [ ]:
def filecopy(f1,f2):
fp=open(f1,'r')
fp1=open(f2,'w')
l=fp.readline()
while l!='':
fp1.write(l)
l=fp.readline()
fp.close()
fp1.close()
In [2]:
import os
print(os.getcwd())
In [7]:
filecopy('corona.txt.txt','covid.txt')
In [8]:
def filecpy(f1,f2):
fp=open(f1,'r')
fp1=open(f2,'w')
l=fp.read()
fp1.write(l)
fp.close()
fp1.close()
In [9]:
filecpy('covid.txt','covid19.txt')
In [10]:
def fileread(f):
fl=open(f)
print(fl.read())
In [11]:
fileread('covid19.txt')
In [13]:
fileread('corona.txt.txt')
In [14]:
fileread('covid19.txt')
In [15]:
def filereadlines(f):
fl=open(f)
print(fl.readlines())
In [16]:
filereadlines('covid19.txt')
In [18]:
def filereadline(f):
fl=open(f)
l=fl.readline()
while l!='':
print(l)
l=fl.readline()
fl.close()
In [3]:
def countline(f):
py=0
fl=open(f)
l=fl.readline()
while l!='':
print(l)
py+=1
l=fl.readline()
print('number of lines in file is ',py)
fl.close()
In [4]:
countline('covid.txt')
In [ ]:
def exam():
No comments:
Post a Comment