python调用shell该引用到什么类_python调用shell, shell 引用python
標(biāo)簽:
python 調(diào)用 shell
get_line_num="wc -l as_uniq_info | awk ‘{print $1}‘" ###get the lines of "as_uniq_info"
line_num =os.popen(get_line_num).read().strip(‘\n‘)
get_line_num 作為shell執(zhí)行的命令,會(huì)取得文件as_uniq_info文件的行數(shù)
os.popen(get_line_num):執(zhí)行shell
get_line_num = os.popen(get_line_num).read():調(diào)用read,賦值給get_line_num,此時(shí)get_line_num中含有一個(gè)換行符("\n")。
os.popen(get_line_num).read().strip(‘\n‘):去掉換行符
shell 引用python變量
line_num?=?os.popen(get_line_num)
引用了python中的get_line_num變量。
python引用shell中值
line_num?=?os.popen(get_line_num).read()
執(zhí)行完shell后,通過read()函數(shù),賦值給python中的變量line_num
標(biāo)簽:
總結(jié)
以上是生活随笔為你收集整理的python调用shell该引用到什么类_python调用shell, shell 引用python的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 知识图谱入门知识(五)【转】秒懂词向量W
- 下一篇: java 类的高级特性_java程序-类