二进制文件的读写-python3

"""
二进制文件的读写

版本: v1.0
日期: 2019.03.28
作者: Catherine
python版本: 3.7
"""


def main():
    try:
        with open('mm.jpg', 'rb') as fs1:
            data = fs1.read()
            print(type(data))
        with open('mm_copy.jpg', 'wb') as fs2:
            fs2.write(data)
    except FileNotFoundError as e:
        print('指定的文件无法打开')
    except IOError as e:
        print('读写文件时出现错误.')
    print('程序执行结束.')


if __name__ == '__main__':
    main()

猜你喜欢

转载自blog.csdn.net/u011280600/article/details/89133319