-1
我是新來的python和在Linux中使用python2.7,我寫了如下的小python程序,但我想將每個文件名存儲到一個variable(index_list[1],...)
。如何從python存儲數組中的文件名
index_list=[]
index_list=commands.getoutput('find /etl/input/ -maxdepth 6 -iname "*tmp" ')
print index_list[1]
感謝, 普拉薩德
感謝威廉·Onsem,但我想使用*在我的程序中找到命令*,輸出將以數組格式存儲。例如,我的find命令獲得4個文件名,每個文件名應該存儲在var [1],var [2]等其他變量中。etc – Prasad
因此,將'command.getoutput('yourcommandhere')的輸出保存到變量然後按'\ n'ex分割:'index_list = index_list.split('\ n')' –
感謝它現在的工作 – Prasad