Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def ReadFile():
- try:
- file1 = open('a.txt','r')
- data = file1.read()
- print(data)
- file1.close()
- except IOError:
- print('Error reading file')
- def WriteFile():
- try:
- file2 = open('c.txt','x')
- file2.write('\nthis is writing by program')
- file2.close()
- except IOError:
- print('File Error')
- def SearchFile(key):
- try:
- file = open('a.txt','r')
- lines = file.readlines()
- for data in lines:
- #print(data)
- if data.strip() == key:
- print(f'{key} is here!')
- file.close()
- except IOError:
- print('File Error')
- # Start Here
- # ReadFile()
- # WriteFile()
- SearchFile('pineapple')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement