python脚本,方便工作,ubuntu下很方便

相比于windows的图形方式,ubuntu的命令行显得简单很多,但是每次需要打开命令行去寻找路径,打开应用程序还是不方便。

以下使用python写了一个小脚本,方便启动常用的工具,初学python,还请多指教,hehe。

#coding=utf-8
#!/usr/bin/python
# start.py

import sys
import os

commandDict = {
    "idea" : "/home/cwz/tools/idea-IU-129.1525/bin/idea.sh",
    "eclipse":"/home/cwz/tools/eclipse/eclipse",
    "genymotion":"/home/cwz/VirtualBox\ VMs/genymotion/genymotion/genymotion"
}

# 判断用户是否输入了参数
if len(sys.argv) <= 1 :
    print '请输入要打开的程序简称'
    print 'python start.py -help for help'
    exit()

# 判断用户输入-help时,输出所有可执行的命令
if sys.argv[1].startswith('-'):
    option = sys.argv[1][1:]
    if option == 'help' :
        print '------------------command dict start-----------------------'
        for command in commandDict:
            print command,':',commandDict.get(command)
        print '------------------command dict end-------------------------'

# 打开应用程序
if commandDict.has_key(sys.argv[1]):
    os.system(commandDict.get(sys.argv[1]))


转载于:https://my.oschina.net/cwzhang/blog/292293

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值