afile = xxx.hanshu() //以函数的形式得到文件(也可以是其他方式)
with open(xxx.xx, 'wb') as f: //xxx.xx 新的文件名 'wb'是字节写入
f.write(afile) //往文件中写入afile
PS: 'w+' 是文本写入,'wb'是字节写入
w+ (多了换行)
hello
world
-----------------------------------
wb
hello
world
--打开文件
open(filepath, 'rb') //filepath文件路径 rb按照二进制位进行读取