我有一個列表,我使用for循環生成。返回:python:如何返回列2列/索引
home1-0002_UUID 3457077784 2132011944 1307504896 62%
home1-0003_UUID 3457077784 2088064860 1351451980 61%
home1-0001_UUID 3457077784 2092270236 1347246604 61%
我怎麼能只返回第三和第五列?
編輯 當我得到它說「Nonetype」對象不是可迭代
for index, elem in enumerate(my_list):
print (index,elem)
我也試圖通過使用列表(枚舉(my_list))來獲得指數,但它不工作,我的錯誤獲得類型錯誤:「NoneType」對象不是可迭代
我這是怎麼填充列表:
def h1ost():
p1 = subprocess.Popen("/opt/lustre-gem_s/default/bin/lfs df /lustre/home1 | sort -r -nk5",stdout=subprocess.PIPE, shell=True)
use = p1.communicate()[0]
for o in use.split('\n')[:6]:
if "Available" not in o and "summary" not in o:
print (o)
如何列表分離的任何空字符串?你能添加實際的輸出嗎?這是一個列表還是數據框? – depperm
'[[col [2],col [4]] col in the_list]'? – Claudiu
它是一個數組的數組? – depperm