不同的获得之间的输出?(Different to get the output between?)

2019-10-29 17:25发布

可以是任何不同,以获得下一个命令之间的输出:

lsof_list = commands.getoutput('lsof  | awk \'{print $1,$2,$5}\')

要么:

lsof_list1 = commands.getoutput('lsof  | awk \'{print $1}\')
lsof_list2 = commands.getoutput('lsof  | awk \'{print $2}\')
lsof_list5 = commands.getoutput('lsof  | awk \'{print $5}\') 
lsof_list = [lsof_list1, lsof_list2, lsof_list5]

当然,行会是列,反之亦然,但我怀疑主要是关于数据,可可能会有在代码工作时间不同数量的打开文件?

可以肯定,有没有在同一时间执行Python中的几条命令的任何功能?

Answer 1:

是啊有可以在输出差。 在第一种情况下正在执行lsof仅一次,然后从捕获值lsof输出,但在第二壳体lsof被exeucted 3倍这可能导致不同的输出。



文章来源: Different to get the output between?
标签: python linux