您要这样做吗?
dict( (name,eval(name)) for name in ['some','list','of','vars'] )
例
>>> some= 1>>> list= 2>>> of= 3>>> vars= 4>>> dict( (name,eval(name)) for name in ['some','list','of','vars'] ){'list': 2, 'some': 1, 'vars': 4, 'of': 3}
欢迎分享,转载请注明来源:内存溢出
您要这样做吗?
dict( (name,eval(name)) for name in ['some','list','of','vars'] )
例
>>> some= 1>>> list= 2>>> of= 3>>> vars= 4>>> dict( (name,eval(name)) for name in ['some','list','of','vars'] ){'list': 2, 'some': 1, 'vars': 4, 'of': 3}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)