• python操作文件模式的介绍

    1、只读模式(只读数据r)。 f = open(‘my_file.txt’, ‘rb’) f_bytes = f.read() print(f_bytes) print(f_bytes.decode(‘utf-8’)) f.close() 2、只写模式(重写数据w),以二进制的方式写入数据或只写模式追加数据。 write_file = open(‘demo1.jpg’, mode=’wb’) read_file = open(‘demo.jpg’, mode=’rb’) write_file.w…

    影音 2021年8月18日