If I'm use command python main.py -h Return "Home" If use command python main.py -c Return "Home" not "a"
Where is a problem ? :<
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import getopt
######################################################################################
def usage():
print "Home"
#if __name__ == "__main__":
try:
opts, args = getopt.getopt(sys.argv[1:], "h:c:u", ["help", "connect", "upload="])
except getopt.GetoptError:
usage()
sys.exit(2)
for opt, arg in opts:
if opt in ("-h", "--help"):
usage()
elif opt in ("-u", "--upload"):
file = args
if not file:
print "Nie wybrano pliku!"
else:
print "Wybrany plik",file
elif opt in ("-c", "--connect"):
print "a"
Aucun commentaire:
Enregistrer un commentaire