def test():
sudoPassword = 'test'
command = '/opt/lampp/lampp stopmysql'
str = os.system('echo %s|sudo -S %s' % (sudoPassword, command))
print str

或:

(status, result)=commands.getstatusoutput('echo %s| sudo -S %s' %(PASSWORD,cmd))

最新文章

  1. 安装zeppelin
  2. maven install 构建报错(2)
  3. Python模拟实现Linux系统unix2dos功能
  4. MySQL查询语句完整语法解析
  5. Android 使用xml序列化器生成xml文件
  6. Java应用程序项目的打包与发行(run.bat形式)
  7. Lintcode: Merge Sorted Array II
  8. Nmap使用指南(1)
  9. tyvj 1055 区间dp
  10. 第三百零二天 how can I 坚持
  11. 【转】Contrary to the answers here, you DON'T need to worry about encoding!
  12. Cannot modify header information - headers already sent by
  13. mbed列--基于飞思卡尔FRDM KL25Z鼠标设计的高速实现
  14. bootstrap+jQuery.validate
  15. 重启oracle数据库的一次操作命令和alter日志。
  16. JavaScript中数组map()方法
  17. 分布式版本库——Windows下Git的环境部署以及在GitHub上开源自己的项目
  18. textarea去掉右下角拖拽
  19. openstack搭建之-glance配置(9)
  20. with(window) onload=onresize=function(){} 写法

热门文章

  1. c#和java中封装字段的不同
  2. CSS3 图标神器 => content:"我是特殊符号"
  3. 关于C#的强制转换和尝试转换的方法
  4. http协议的各类状态码
  5. 【10】Quartz.net 定时服务实例
  6. 10、List、Set
  7. Core.Java.Volume.I.Fundamentals.10th.Edition 14.5.8 Volatile域 中文版 章节勘误
  8. HDU 2546(01背包)
  9. 类库项目如何既能支持netcore2.0,也能支持net4.5
  10. vue项目性能优化(路由懒加载、gzip加速、cdn加速)