I am newbie who can explain this code to me?
380162267qq at gmail.com
380162267qq at gmail.com
Tue Sep 20 08:34:38 EDT 2016
在 2016年9月20日星期二 UTC-4上午8:17:13,BartC写道:
> On 20/09/2016 13:12, 380162267qq at gmail.com wrote:
> >>>> d = {}
> >>>> keys = range(256)
> >>>> vals = map(chr, keys)
> >>>> map(operator.setitem, [d]*len(keys), keys, vals)
> >
> > It is from python library. What does [d]*len(keys) mean?
> > d is the name of dict but put d in [] really confused me.
> >
>
> if len(keys) is 5 then [d]*5 is:
>
> [d,d,d,d,d]
>
> [d] is a list, containing one item, a dict if that is what it is.
>
> --
> Bartc
Thank you. I understand now
More information about the Python-list
mailing list