如何将列表的变量转换为单独的列表

时间:2016-04-01 03:24:55

标签: python list binary

我想将我拥有的列表转换为单独的列表

我拥有的内容:x = ['0b1001000', '0b1100101', '0b1101100', '0b1101100', '0b1101111']

我想要的是什么:

x1 = ['0,1,0,0,1,0,0,0']
x2 = ['0,1,1,0,0,1,0,1'] 
x3 = ['0,1,1,0,1,1,0,0']
x4 = ['0,1,1,0,1,1,0,0'] 
x5 = ['0,1,1,0,1,1,1,1']

2 个答案:

答案 0 :(得分:0)

我的意思是:

>> [list(filter(str.isdigit, ele)) for ele in x]
[['0', '1', '0', '0', '1', '0', '0', '0'], ['0', '1', '1', '0', '0', '1', '0', '1'], ['0', '1', '1', '0', '1', '1', '0', '0'], ['0', '1', '1', '0', '1', '1', '0', '0'], ['0', '1', '1', '0', '1', '1', '1', '1']]

答案 1 :(得分:0)

x = ['0b1001000', '0b1100101', '0b1101100', '0b1101100', '0b1101111']
for each in x:
    k = filter(str.isdigit,each)
    print list(k)