字典问题
本帖最后由 yangge9 于 2020-4-12 23:35 编辑>>> dict3={}
>>> dict3.fromkeys(range(20),'赞')
{0: '赞', 1: '赞', 2: '赞', 3: '赞', 4: '赞', 5: '赞', 6: '赞', 7: '赞', 8: '赞', 9: '赞', 10: '赞', 11: '赞', 12: '赞', 13: '赞', 14: '赞', 15: '赞', 16: '赞', 17: '赞', 18: '赞', 19: '赞'}
>>> dict3
{}
请问为什么返回的是一个空字典呢 本帖最后由 yangge9 于 2020-4-12 23:38 编辑
解决了忘记打dict3= fromkeys是类方法,应该把返回值赋给dict3 {}是不是python语言中没有?
页:
[1]