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

 

posted @ 2019-01-31 16:35  effortsing  阅读(163)  评论(0编辑  收藏  举报