本文实例讲述了jscr ipt读写二进制文件的方法。分享给大家供大家参考。具体实现方法如下:
var bin = new Array(256);
for(var i=0;i<256;i++){
bin[i]=String.fromCharCode(i);
}
function TestWrite(){
var Stream = new ActiveXObject("ADODB.Stream");
var adTypeBinary=1,adTypeText=2;
Strea
问题
你想读写二进制文件,比如图片,声音文件等等。
解决方案
使用模式为 rb 或 wb 的 open() 函数来读取或写入二进制数据。比如:
# 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.wr