strip使用
strip作用:去掉空格、以及想要去掉的字符,实例如下: In [42]: import subprocess In [42]: output=subprocess.check_output(["kubectl get no | grep test2 | awk '{print $1}'"], shell=True) In [43]: line=output.decode('utf8').strip() In [44]: print(line) test2
strip作用:去掉空格、以及想要去掉的字符,实例如下: In [42]: import subprocess In [42]: output=subprocess.check_output(["kubectl get no | grep test2 | awk '{print $1}'"], shell=True) In [43]: line=output.decode('utf8').strip() In [44]: print(line) test2