Comment afficher un argument sans l'aide d'une option
Bonjour, comment peut-on afficher simplement l'argument qui suit l'appel d'une fonction .py sans utiliser une option telle que "-h", "-e", "--affiche"... ?
J'ai commencé à faire cette fonction dans mon fichier :
Code:
1 2 3 4 5 6 7 8 9 10
|
def affiche():
from optparse import OptionParser
parser = OptionParser()
parser.add_option(" " action='store', dest="mot", help="Affiche l'argument")
parser.set_defaults(mot="Aucun argument")
parser.usage += '[args]'
options, arguments = parser.parse_args()
print "L'argument est :",options.mot |
En tapant :
./fic.py bonjour
je veux afficher "L'argument est : bonjour"
Merci