problem: want write directory's path user's input in add.argument of argumentparser().
so far: have written
import argparse parser = argparse.argumentparser() parser.add_argument('path', option = os.chdir(input("paste here path biog.txt file:")), help= 'paste path biog.txt file')
any idea's, ideal solution of problem ?
you can use like:
import argparse, os parser = argparse.argumentparser() parser.add_argument('--path', help= 'paste path biog.txt file') args = parser.parse_args() os.chdir(args.path) # change directory argument passed '--path' print os.getcwd()
pass directory path argument --path
while running script. also, check official document correct usage of argparse
: https://docs.python.org/2/howto/argparse.html
Comments
Post a Comment