Can sys.argv handle optional arguments? [duplicate]

Just use the length of sys.argv

if len(sys.argv) == 2:
  # do X
else:
  # do Y

Leave a Comment