python调用shell小技巧
2016-05-14 23:35
495 查看
#!/bin/env python
import os,sys
Dir = os.popen("basename /root/day1/myfire.py")
print Dir.read().strip('\n')
另一种获取文件名和其路径的方法
在工作中遇到很多ICE启动后进程名都一样,难以分辨,现在有了python大法,可以轻易的通过
2,三行代码来解决这个问题
end !
import os,sys
Dir = os.popen("basename /root/day1/myfire.py")
print Dir.read().strip('\n')
另一种获取文件名和其路径的方法
from nt import chdir, listdir,getcwd from os.path import basename import os chdir('c:\\') print(getcwd()) print(listdir()) print(basename('C:\\QcOSD.txt')) print(os.path.dirname('C:\\QcOSD.txt'))
在工作中遇到很多ICE启动后进程名都一样,难以分辨,现在有了python大法,可以轻易的通过
2,三行代码来解决这个问题
#!/usr/local/bin/python3.5 import psutil for i in psutil.pids(): p = psutil.Process(i) print(str(p.pid),p.exe(),p.cwd())
end !
相关文章推荐
- UBUNTU实战(5)
- Linux Bash终端快捷键小结
- Linux汇编和Shellcoding-1 汇编语言简介
- Linux Bash终端支持中文显示
- shell脚本学习02-第一章小结
- shell脚本学习01
- 批量修改文件名的脚本bat\python\shell
- 【Linux】Shell三类变量的作用域——linux shell “永久环境变量”、“临时环境变量”和"普通变量"之完全解读
- Shell脚本的一些参数
- Bash通配符及特殊符号
- shell脚本分为三类:登录脚本、交互式脚本、非交互式脚本
- linux shell编程学习--日志工具
- linux shell编程学习--test测试比较命令
- Spark入门实战系列--3.Spark编程模型(上)--编程模型及SparkShell实战
- shell(二)Bash常用快捷键
- Shell命令行快捷键
- shell实现输入密码显示星号
- shell script 交互式脚本,可以读取命令行参数、选项,用户输入数据
- 第二节windows系统下Xshell 5软件远程访问虚拟机 Linux系统
- shell原理和问答机制引入