其他分享
首页 > 其他分享> > 第十yi集:文件操作模式

第十yi集:文件操作模式

作者:互联网

'''
文件操作模式

'''
fp = open('too.txt','a',encoding='utf=8')
fp.write('\n你好')
fp.close()

# fl =

# 文件操作的高级操作
'''
with open(文件路径 打开模式)
'''
# r+即可读又可写
with open('too.txt','r+',encoding='utf=8') as fp:
ss=fp.read()
# 设置指针的位置
# fp.seek(1)
print('高级写法',ss)
fp.write(ss)

# # w+即可读又可写 打开后清空
# with open('too.txt','w+',encoding='utf=8') as fp:
# ss=fp.read()
# print('高级写法',ss)
# fp.write(ss)

标签:yi,文件,第十,ss,encoding,write,fp,txt,open
来源: https://www.cnblogs.com/cyz-2020/p/15942915.html