zoukankan      html  css  js  c++  java
  • python调用shell, shell 引用python

    python 调用 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(' ')

    get_line_num 作为shell执行的命令,会取得文件as_uniq_info文件的行数

    os.popen(get_line_num):执行shell

    get_line_num = os.popen(get_line_num).read():调用read,赋值给get_line_num,此时get_line_num中含有一个换行符(" ")。

    os.popen(get_line_num).read().strip(' '):去掉换行符

    shell 引用python变量

    line_num = os.popen(get_line_num)  

    引用了python中的get_line_num变量。

    python引用shell中值

    line_num = os.popen(get_line_num).read()  

    执行完shell后,通过read()函数,赋值给python中的变量line_num

  • 相关阅读:
    SQL_50题
    Java多线程之冰山一角
    概览
    Selector
    集群配置
    redis config
    分布式、集群
    redis相关技术总结
    redis scan扫描
    redis 单线程 多路io复用
  • 原文地址:https://www.cnblogs.com/timssd/p/4688041.html
Copyright © 2011-2022 走看看