def min1(args): res=args[0] for arg in args[1:]: if arg<res: res=arg return res def min2(first,rest): for arg in rest: if arg<first: first=arg return first def min3(args): tmp=list(args) tmp.sort() return tmp[0] print 'Please in put a min func from min1,min2,min3\n' print 'min1(*args) min2(first,*rest) min3(*args)\n' print 'Please input a sequence to min1 and min3\n' inputword=raw_input() inputword=inputword.split(',') print 'Please input first parameter to min2\n' first=raw_input() print 'Please input second parameter to min2\n' second=raw_input() second=second.split(',') print min1(inputword),'-----------',min2(first,second),'-----------',min3(inputword) raw_input()
如果函数写成*args的任意参数形式,则args会被识别成(['1', '2', '3'],)这样的元组,因此不能满足需求。