1

my project is handle three arguments how to handle this my code like this

def main(argv):
try:
    opts, args = getopt.getopt(argv,"d:f:w:",['--i','--u','--v'])
    print opts
    print args

except getopt.GetoptError:
    print 'Option Error'

if __name__ == '__main__':
    try:
        main(sys.argv[1:])
    except Exception, e:
        print str(e)

i will run this code i will get this ouptut ./code.py -d --i -f --u package1 package2 output is

[('-d', '--i'), ('-f', '--u')]
['package1', 'package2']

but i will expect output like this format how to modify, ./code.py -d --i package1 -f --u package2 ...

[('-d', '--i',), ('-f', '--u')]
['package1', 'package2']
4

1 に答える 1