欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

python 執(zhí)行文件時額外參數(shù)獲取的實(shí)例

 更新時間:2018年12月18日 09:15:05   作者:To be a cool guy  
今天小編就為大家分享一篇python 執(zhí)行文件時額外參數(shù)獲取的實(shí)例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧

如下所示:

def usage():
  print(' * usage:')
  print(' *  -c [val] : exporter_conf filepath, default importer_conf.')
  print(' *  -h : print this.')
  print(' *  -z : 不需要確認(rèn)參數(shù),直接執(zhí)行')


do_not_confirm = False

conf = ''
#c: [c+冒號表示-c 后面有參數(shù),hz表示-h,-z后面沒參數(shù),如果此時在-h 100加上參數(shù),那么這個100的值是獲取不到的] 
opts, args = getopt.getopt(sys.argv[1:], 'c:hz') 
for op, value in opts:
  value = value.replace('\'', '').replace('\"', '')
  if op == '-c':
    conf = value
  elif op == '-h':
    usage()
    sys.exit()
  elif op == '-z':
    do_not_confirm = True

以上這篇python 執(zhí)行文件時額外參數(shù)獲取的實(shí)例就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論