filepath='d:/note1.txt'
file1=open(filepath)
print(file1.read())
for i in range(2):
print(file1.readline())
print(file1.readlines())
file1.close()
filepath='d:/note210307_1.txt'
file1=open(filepath,'w+')
file1.write('好雨知时节,当春乃发生.随风潜入夜,润物细无声.野径云俱黑,江船火独明.晓看红湿处,花重锦官城')
file1.seek(0)
print(file1.read())
file1.close()
filepath='d:/note210307_1.txt'
file1=open(filepath)
file1.seek(11)
print(file1.read())
file1.close()
filepath1='d:/note210307_1.txt'
filepath2='d:/note210307.txt'
with open(filepath1) as file1,open(filepath2) as file2:
print(file1.read())
print(file2.read())
with open('d:/自然数210307.txt','w+') as file1:
for i in range(1,101):
if i==100:
file1.write(str(i))
else:
file1.write(str(i)+',')