📜  python 附加字节中的文件处理 - Python 代码示例

📅  最后修改于: 2022-03-11 14:47:14.393000             🧑  作者: Mango

代码示例1
file = open('myfile.dat', 'wb')
file.write('This is a sample')
file.close()

file = open('myfile.dat', 'ab')
file.seek(5)
file.write(' text')
file.close()

file = open('myfile.dat', 'rb')
print file.read()  # -> This is a sample text