我有下一个string
:
string = 'tuned 1372 root 6u REG 8,3 4096 102029349 /tmp/ffiabNswC (deleted)\ngmain 1372 2614 root 6u REG 8,3 4096 102029349 /tmp/ffiabNswC (deleted)\n'
我需要将string
的每个元素放入list1[0][..]
,但是当我看到一个新行'\n'时,我必须将下一个元素放入list1[1][..]
多维列表,如下图所示:
^{pr2}$我用split
来做,但它把我放在同一个维度上。在
在输入:-在
代码:-写下来
^{pr2}$在输出:-在
首先按新行拆分(以获取行),然后按空格拆分每个元素(以获取每个列):
以下功能将为您完成此操作:
只需通过
f(string)
调用它。在如果你不想在你的子列表中有任何空的条目,你可以这样做
^{pr2}$相关问题 更多 >
编程相关推荐