小时? 发表于 2017-5-4 10:44:59

Example of Using getopt in Python

import getopt, sys
def main():
try:
opts, args = getopt.getopt(sys.argv, "ho:v", ["help", "output="])
except getopt.GetoptError:
# print help information and exit:
usage()
sys.exit(2)
output = None
verbose = False
for o, a in opts:
if o == "-v":
verbose = True
if o in ("-h", "--help"):
usage()
sys.exit()
if o in ("-o", "--output"):
output = a
  中午详细解释看这里。
页: [1]
查看完整版本: Example of Using getopt in Python