Using PyCharm, I noticed it offers to convert a dict literal:
d = {
'one': '1',
'two': '2',
}
into a dict constructor:
d = dict(one='1', two='2')
Do these different approaches differ in some significant way?
(While writing this question I noticed that using dict()
it seems impossible to specify a numeric key .. d = {1: 'one', 2: 'two'}
is possible, but, obviously, dict(1='one' ...)
is not. Anything else?)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…