0

I'd like to use option parser to print the result of a computation to the command line. So far, I have

parser = OptionParser()
parser.add_option('-s','--some', help = "Print some of the Suspects")
parser.add_option('-a','--all',help = "Print all of the Suspects")

(opts,args) = parser.parse_args()

If the user passes -s, I would like the first 25 rows of a dataframe to be printed (I know how to do this). If -a is passed, I would like the entire dataframe to be printed. What do I have left to do?

4

1 回答 1

1
from optparse import OptionParser

parser = OptionParser()
parser.add_option('-s','--some', help = "Print some of the Suspects")
parser.add_option('-a','--all',help = "Print all of the Suspects")

(opts,args) = parser.parse_args()

if opts.some:
    print "some results"
if opts.all:
    print "all results"
于 2015-11-16T21:25:50.377 回答