我们正在打印时获取数组值。获取以下输出。命令:
import subprocess
output = [subprocess.check_output("kapacitor list tasks | grep -i enabled | cut -d ' ' -f1", shell=True)]
打印阵列时:
`['tAlert_ALL_metrics_cpu\ntAlert_ALL_metrics_memory_usage\ntAlert_ALL_oracle_TBS_offline\ntAlert_NN_WMS_endpoint-message-count_MSE\ntAlert_NN_ecom_version_check\ntAlert_NN_ecom_version_check_all_farms\ntAlert_NN_metrics_fileSystem\ntAlert_NWNA_metrics_fileSystem\n'] `
预期输出如下:
output[0]= tAlert_ALL_metrics_cpu\ntAlert_ALL_metrics_memory_usage
output[1]= tAlert_ALL_oracle_TBS_offline
output[2]= tAlert_NN_WMS_endpoint-message-count_MSE
同时在检查数组长度时,显示为1
length = len(output)
假设你的输出是
然后你可以这样做:
相关问题 更多 >
编程相关推荐