python调用shell, shell 引用python
2016-07-01 02:41
441 查看
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('\n')
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中含有一个换行符("\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()
执行完shell后,通过read()函数,赋值给python中的变量line_num
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执行的命令,会取得文件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中含有一个换行符("\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()
执行完shell后,通过read()函数,赋值给python中的变量line_num
相关文章推荐
- shell 脚本
- linux shell “(())” 双括号运算符使用
- shell脚本实现拷贝大文件显示百分比的代码分享
- Shell中的循环
- 深入浅出ShellExecute
- Linux常用的shell命令汇总
- shell脚本中字符串截取的多种方法
- 添加bash命令
- linux下,shell如何删除指定字符间的内容
- 启动一个shell脚本项目
- Linux Shell格式化Json
- 希尔排序(ShellSort程序完整版)
- shell 脚本hello world
- Ubuntu每次打开终端出现错误提示的解决方法
- Shell脚本生成网页版相册浏览器
- Shell脚本生成网页版相册浏览器
- 提交spark作业:如何在java中执行shell脚本
- 网卡流量监控脚本 ( Shell )
- powershell玩转SQL SERVER所有版本
- Linux SSH 远程登录后显示-bash-4.1$的解决办法(原创)