⽂件操作的写(w,wb,w+)⽂件操作的写(w,wb,w+)
w
没有⽂件,创建⽂件,写⼊内容
如果⽂件存在,先清空⽂件内容,在写⼊新内容
f1=open('你简单,世界就是童话',encoding='utf-8',mode='w')
print(f1.write('当哭成为表演,就应当允许有⼈不哭!'))
f1.close()
得:17(⽂字个数)
创建html文件
wb
如果要写⼊⽂件,先把⽂件转换成bytes格式,在写⼊
s1=open('timg (3).jpg',mode='rb')
ad()
s1.close()
f1=open('motuo.jpg',mode='wb')
print(f1.write(count))
f1.close()
w+ 写读
with open('简单',encoding='utf-8',mode='w+')as f1:
f1.write('3⽉19⽇')
f1.seek(0)
ll())
ad())

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。