2025-09-10:仓库迁移
This commit is contained in:
12
5.文件与IO/17.将字节数据写入文本文件.py
Normal file
12
5.文件与IO/17.将字节数据写入文本文件.py
Normal file
@@ -0,0 +1,12 @@
|
||||
import io
|
||||
|
||||
if __name__ == "__main__":
|
||||
file = "5.文件与IO/17.try.txt"
|
||||
|
||||
# 上一章我们知道了文件打开后都长什么样子,想要往文件里写字节数据怎么办?直接往buffer里怼就完了、
|
||||
# 这样可以绕过文件的编码层
|
||||
f = open(file, "w")
|
||||
f.buffer.write(b"write")
|
||||
|
||||
|
||||
f.close()
|
Reference in New Issue
Block a user