0
我需要使用列表值作爲變量。它怎麼能做到。如何使用列表數據作爲變量
comp_list = [ "list1", " list2", "list3"]
for comp in comp_list:
print (comp)
cmd = 'ps -aef | grep $comp'<<<<
print (cmd)
status, command = getstatusoutput(cmd)
的<<<
引導到$comp
應list1
被替換,然後list2
,它應該繼續下去。
你的意思是你需要用'comp'的值替換'$ comp'? – justanothercoder 2014-08-29 05:29:38
''ps -aef | grep'+ str(comp)' – 2014-08-29 05:36:50