python 字节读写

2019-09-29 20:23:06 浏览数 (1)

Read the entire file as a single byte string

with open('somefile.bin', 'rb') as f: data = f.read()

Write binary data to a file

with open('somefile.bin', 'wb') as f: f.write(b'Hello World')

0 人点赞