多思考,多实践,现状才会改变!

python 不定个数的参数传递

上一篇 / 下一篇  2011-08-16 16:42:08 / 个人分类:python 资料

class ConfigInputs:
    def inputs(self,**map):
        if 'aa' in map:
            print 'success'
            print 'aa',map['aa']
        if 'bb' in map:
            print 'bb pass'
        if 'cc' in map:
            print 'cc pass'

if __name__ == "__main__":
    print 'come here'
    ap = ConfigInputs()
    ap.inputs(aa='ccc',bb='xxx')



运行结果:
D:\Roboshop\roboshop_script\conn2_test\lib>python con_inputs.py
come here
success
aa ccc
bb pass


TAG: Python python 多个参数

 

评分:0

我来说两句

Open Toolbar