Python の使用関数に問題があります。これは私の主な機能の一部です:
def main(argv):
try:
opts, args = getopt.getopt(argv, 'hi:o:tbpms:', ['help', 'input=', 'output='])
if not opts:
print 'No options supplied'
usage()
except getopt.GetoptError,e:
print e
usage()
sys.exit(2)
for opt, arg in opts:
if opt in ('-h', '--help'):
usage()
sys.exit(2)
if __name__ =='__main__':
main(sys.argv[1:])
使用関数も定義します
def usage():
print "\nThis is the usage function\n"
print 'Usage: '+sys.argv[0]+' -i <file1> [option]'
しかし、コードを./code.py
or ./code.py -h
(実行可能) として実行すると、Python のヘルプしか表示されません。