非文本文件的写入

# 在b模式只能写入字节
with open(r"D:\sh_fullstack_s6\day8\代码\test.txt",mode="wb") as f:
    f.write("abc".encode("utf-8"))                    #写的时候需要自己指定编码表
    f.write("你y好".encode("utf-8"))

猜你喜欢

转载自www.cnblogs.com/Hale-wang/p/10354242.html