I'd like to get from this:
keys = [1,2,3]
to this:
{1: None, 2: None, 3: None}
Is there a pythonic way of doing it?
This is an ugly way to do it:
>>> keys = [1,2,3]
>>> dict([(1,2)])
{1: 2}
>>> dict(zip(keys, [None]*len(keys)))
{1: None, 2: None, 3: None}
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…