print('--------------File Type------------')
print('\t')
f01 = open('Sketch.txt', 'r')
print(' ==---read------------')
print(f01.read(5))
print('\r')
print(f01.read())
print('--------------readline-------------')
f02 = open('Sketch.txt', 'r')
print(f02.readline())
print(f02.readline())
print(f02.readline())
print('---------for loop-----------')
f03 = open('sketch.txt', 'r')
for var in f03:
if 'Python lesson' in var:
pass
elif 'sketch' in var:
pass
else:
print(var)
print('\r')
f04 =open('Sketch.txt','r')
print(f04.readline())
f04.close
# Error
#print(f04.readline())
print('---------------write()-----------------')
# a append
f05 = open('Sketch.txt', 'a')
f05.write('New Line, Append')
f05.close
# w overwrite
f06 = open('Sketch.txt', 'w')
f06.write('New Line, Overwrite')
f06.close
No comments:
Post a Comment