使用getstatusoutput命令python获得额外的0

时间:2021-04-25 00:16:01
live_calls = commands.getstatusoutput('/usr/local/freeswitch/bin/fs_cli -x "show calls")

current_live_agent = commands.getstatus('/usr/local/freeswitch/bin/fs_cli -x "show bridged_calls"  |tail -2 | grep -o "[0-9]*"')   
print(current_live_agent)

I am using above commands then getting out like (0 '0') i want to get first 0 only. Can someone help me. Thanks in advance

我正在使用上面的命令,然后像(0'0')一样出来我想先得到0。有人能帮我吗。提前致谢

1 个解决方案

#1


0  

commands.getstatusoutput returns a tuple: (status, output). So, to access the status (first element):

commands.getstatusoutput返回一个元组:(状态,输出)。所以,要访问状态(第一个元素):

live_calls = commands.getstatusoutput('/usr/local/freeswitch/bin/fs_cli -x "show calls"')
print("status: {0}".format(live_calls[0]))
print("output: {0}".format(live_calls[1]))

#1


0  

commands.getstatusoutput returns a tuple: (status, output). So, to access the status (first element):

commands.getstatusoutput返回一个元组:(状态,输出)。所以,要访问状态(第一个元素):

live_calls = commands.getstatusoutput('/usr/local/freeswitch/bin/fs_cli -x "show calls"')
print("status: {0}".format(live_calls[0]))
print("output: {0}".format(live_calls[1]))