課程
/后端開發
/Python
/初識Python
既然itervalues()比values()省內存,iteritems()也比items()省內存,什么情況下用后兩個比較好呢
2016-01-11
源自:初識Python 9-4
正在回答
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
a=d.itervalues(); #return an dictionary-iterator object with the count and each value
b=d.values(); #return the value list
如果需要一個list作為其他的用途,可以用values()和items()返回一個list,保存起來。以后用的時候就直接用這個list就好了
就沒有必要使用后2個了。
舉報
學python入門視頻教程,讓你快速入門并能編寫簡單的Python程序
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2016-01-28
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
a=d.itervalues(); #return an dictionary-iterator object with the count and each value
b=d.values(); #return the value list
2016-01-17
如果需要一個list作為其他的用途,可以用values()和items()返回一個list,保存起來。以后用的時候就直接用這個list就好了
2016-01-11
就沒有必要使用后2個了。