将下面的字符串转化为列表:
['0000000000000000000000000000000000000001,192.168.131.37,16,0.2.3.3,34,768,1,0x0010,0x88,5.2.3.4,1', '0000000000000000000000000000000000000003,2.37.13.52,4352,2.2.3.3,34,768,1,0x1011,0x88,2.136.136.2,0', '']
想要达到的效果:
去掉单引号后几个字符串的连接,如下:
0000000000000000000000000000000000000001,192.168.131.37,16,0.2.3.3,34,768,1,0x0010,0x88,5.2.3.4,1,0000000000000000000000000000000000000003,2.37.13.52,4352,2.2.3.3,34,768,1,0x1011,0x88,2.136.136.2,0
最初使用了如下方法:
得到的结果为:
0000000000000000000000000000000000000001,192.168.131.37,16,0.2.3.3,34,768,1,0x0010,0x88,5.2.3.4,10000000000000000000000000000000000000003,2.37.13.52,4352,2.2.3.3,34,768,1,0x1011,0x88,2.136.136.2,0
后改为join方法,达到了想要的效果:
ww=','.join(qq)
列表各元素间用逗号(,)分割
0000000000000000000000000000000000000001,192.168.131.37,16,0.2.3.3,34,768,1,0x0010,0x88,5.2.3.4,1,0000000000000000000000000000000000000003,2.37.13.52,4352,2.2.3.3,34,768,1,0x1011,0x88,2.136.136.2,0
ww为连接后的字符串,qq为最初的列表