# open file and read file
f = open('new.txt','r')
print(f.read())

#  read by specified text
f = open('new.txt','r')
print(f.read(7))

# print one line only
f = open('new.txt','r')
print(f.readline())

# print first two lines
f = open('new.txt','r')
print(f.readline(),end="")
print(f.readline())

# print file content with loop
files = open('new.txt','r')
for i in files:
    print(i,end="")

# close file
f = open('new.txt','r')
print(f.read())
f.close()

# append data
f = open('new.txt','a')
f.write("\nThis is new line in text file")
f.close()
print('data added ')

# add data and open file again
f = open('new.txt','a')
f.write("\nThis new line in file ")
f.close()
f = open('new.txt','r')
print(f.read())

# overwrite file content
f = open('new.txt', 'w')
f.write("This is override all content")
f.close()
f = open('new.txt', 'r')
print(f.read())

# create new file
# f = open('one.txt','x')

# create new file
# f = open('two.txt', 'w')
# print('file created')

# delete file
# import os
#
# os.remove('two.txt')
# print("file removed")


# check file exits or not
import os

if os.path.exists('two.txt'):
    os.remove('two.txt')
else:
    print("file not exist")

# delete folder
import  os
os.rmdir('demo')
print("folder deleted")



1134ebb3127a0192ba46d10dc5a9544128f7d574
<mask token>

<mask token>
print(f.read())
<mask token>
print(f.read(7))
<mask token>
print(f.readline())
<mask token>
print(f.readline(), end='')
print(f.readline())
<mask token>
for i in files:
    print(i, end='')
<mask token>
print(f.read())
f.close()
<mask token>
f.write("""
This is new line in text file""")
f.close()
print('data added ')
<mask token>
f.write("""
This new line in file """)
f.close()
<mask token>
print(f.read())
<mask token>
f.write('This is override all content')
f.close()
<mask token>
print(f.read())
<mask token>
if os.path.exists('two.txt'):
    os.remove('two.txt')
else:
    print('file not exist')
<mask token>
os.rmdir('demo')
print('folder deleted')

f = open('new.txt', 'r')
print(f.read())
f = open('new.txt', 'r')
print(f.read(7))
f = open('new.txt', 'r')
print(f.readline())
f = open('new.txt', 'r')
print(f.readline(), end='')
print(f.readline())
files = open('new.txt', 'r')
for i in files:
    print(i, end='')
f = open('new.txt', 'r')
print(f.read())
f.close()
f = open('new.txt', 'a')
f.write("""
This is new line in text file""")
f.close()
print('data added ')
f = open('new.txt', 'a')
f.write("""
This new line in file """)
f.close()
f = open('new.txt', 'r')
print(f.read())
f = open('new.txt', 'w')
f.write('This is override all content')
f.close()
f = open('new.txt', 'r')
print(f.read())
<mask token>
if os.path.exists('two.txt'):
    os.remove('two.txt')
else:
    print('file not exist')
<mask token>
os.rmdir('demo')
print('folder deleted')

f = open('new.txt', 'r')
print(f.read())
f = open('new.txt', 'r')
print(f.read(7))
f = open('new.txt', 'r')
print(f.readline())
f = open('new.txt', 'r')
print(f.readline(), end='')
print(f.readline())
files = open('new.txt', 'r')
for i in files:
    print(i, end='')
f = open('new.txt', 'r')
print(f.read())
f.close()
f = open('new.txt', 'a')
f.write("""
This is new line in text file""")
f.close()
print('data added ')
f = open('new.txt', 'a')
f.write("""
This new line in file """)
f.close()
f = open('new.txt', 'r')
print(f.read())
f = open('new.txt', 'w')
f.write('This is override all content')
f.close()
f = open('new.txt', 'r')
print(f.read())
import os
if os.path.exists('two.txt'):
    os.remove('two.txt')
else:
    print('file not exist')
import os
os.rmdir('demo')
print('folder deleted')

# open file and read file
f = open('new.txt','r')
print(f.read())

#  read by specified text
f = open('new.txt','r')
print(f.read(7))

# print one line only
f = open('new.txt','r')
print(f.readline())

# print first two lines
f = open('new.txt','r')
print(f.readline(),end="")
print(f.readline())

# print file content with loop
files = open('new.txt','r')
for i in files:
    print(i,end="")

# close file
f = open('new.txt','r')
print(f.read())
f.close()

# append data
f = open('new.txt','a')
f.write("\nThis is new line in text file")
f.close()
print('data added ')

# add data and open file again
f = open('new.txt','a')
f.write("\nThis new line in file ")
f.close()
f = open('new.txt','r')
print(f.read())

# overwrite file content
f = open('new.txt', 'w')
f.write("This is override all content")
f.close()
f = open('new.txt', 'r')
print(f.read())

# create new file
# f = open('one.txt','x')

# create new file
# f = open('two.txt', 'w')
# print('file created')

# delete file
# import os
#
# os.remove('two.txt')
# print("file removed")


# check file exits or not
import os

if os.path.exists('two.txt'):
    os.remove('two.txt')
else:
    print("file not exist")

# delete folder
import  os
os.rmdir('demo')
print("folder deleted")


