python处理数据文件
2021-02-04 本文已影响0人
Poisson_Lee
#!/usr/bin/env python
a = [0, 1, 2, 3, 4]
for item in range(0, len(a)):
print(a[item])
a = "5a5add11"
print(len(a))
c = a[::2]
print(c)
b = int("5a", 16)
print(b)
print(abs(-1))
def split_line_to_int16(line):
split_result = []
for i in range(0,len(line)/4):
split_result.append(line[i*4:i*4+4])
return split_result
def split_line_to_int8(line):
split_result = []
for i in range(0,len(line)/2):
split_result.append(line[i*2:i*2+2])
return split_result
print(split_line_to_int16("00010000ffffffff00010000ffff0000"))
print(split_line_to_int8("00010000ffffffff00010000ffff0000"))