先上代码:
import sys
fid = open(sys.argv[1],'r')
out_fid = open('split.txt','w')
for dt in fid.readlines():
print(dt)
for n in range(0,8):
s_tmp = dt[14-2*n:16-2*n]
out_fid.write(s_tmp+"\n")
fid.close()
out_fid.close()
以上代码实现了把64bit的字符串转换成8bit字符串。文件名为split64_8bit.py
运行方式,在terminal中输入:
python split6464_8bit.py file.txt
原文本中字符串如下:
分割后如下: