需要产生100行16byte的数据,使用python产生,其中的"{0:0"+str(width)+“b}”).format(value),将value转换成二进制的字符串,长度是width,在前面自动补零
import random
def dict_to_binstr(dict):
ret = ""
for width, value in dict.items():
ret = ret + ("{0:0"+str(width)+"b}").format(value)
return ret
rsvd = 0
dword0 = 0
dword1 = 0
f = open("admin_data.txt", 'w+')
for i in range(100):
sq_id = random.randint(0,4)
p = random.randint(0,1)
sq_head = i
cid = i
sq_head_pointer = i
do_not_try = random.randint(0,1)
more = random.randint(0,1)
status_code_type = random.randint(0,7)
if(i%2==0):
status_code = 0
else :
status_code = random.randint(0,127)
dict = {1:do_not_try,1:more,2:rsvd,3:status_code_type,8:status_code,
1:p,16:cid,16:sq_id,16:sq_head_pointer,32:dword1,32:dword1}
result = dict_to_binstr(d