非文本文件的写入

# 在b模式只能写入字节
with open(r"D:sh_fullstack_s6day8代码	est.txt",mode="wb") as f:
    f.write("abc".encode("utf-8"))                    #写的时候需要自己指定编码表
    f.write("你y好".encode("utf-8"))
原文地址:https://www.cnblogs.com/Hale-wang/p/10354242.html