1 Star 0 Fork 1

zlipper/iridium-toolkit

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
bits_to_dfs.py 1.61 KB
一键复制 编辑 原始数据 按行查看 历史
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vim: set ts=4 sw=4 tw=0 et pm=:
import fileinput
import sys
"""
VOC: i-1443338945.6543-t1 033399141 1625872817 81% 0.027 179 L:no LCW(0,001111,100000000000000000000 E1) 01111001000100010010010011011011011001111 011000010000100001110101111011110010010111011001010001011101010001100000000110010100000110111110010101110101001111010100111001000110100110001110110 1010101010010010001000001110011000001001001010011110011100110100111110001101110010110101010110011101011100011101011000000000 descr_extra:
"""
def turn_symbols(byte):
out = 0
if byte & 0x01:
out |= 0x02
if byte & 0x02:
out |= 0x01
if byte & 0x04:
out |= 0x08
if byte & 0x08:
out |= 0x04
if byte & 0x10:
out |= 0x20
if byte & 0x20:
out |= 0x10
if byte & 0x40:
out |= 0x80
if byte & 0x80:
out |= 0x40
return out
def chunks(l, n):
""" Yield successive n-sized chunks from l.
"""
for i in xrange(0, len(l), n):
yield l[i:i+n]
infile = sys.argv[1]
outfile = open(sys.argv[2], 'wb')
data = ''
for line in fileinput.input(infile):
line = line.split()
if line[0] == 'VOC:':
if int(line[6]) < 179:
continue
data = line[10]
if (data[0] == "["):
for pos in xrange(1,len(data),3):
byte=int(data[pos:pos+2],16)
byte=int('{:08b}'.format(byte)[::-1], 2)
outfile.write(chr(byte))
else:
for bits in chunks(data, 8):
byte = int(bits[::-1],2)
outfile.write(chr(byte))
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zlipper/iridium-toolkit.git
git@gitee.com:zlipper/iridium-toolkit.git
zlipper
iridium-toolkit
iridium-toolkit
master

搜索帮助