Map My Mind
主要是一堆自由軟體學習過程的片段
搜尋此網誌
顯示具有
python
標籤的文章。
顯示所有文章
顯示具有
python
標籤的文章。
顯示所有文章
2012年11月20日 星期二
python 將 for的結果存到list去
一般會這樣寫:
entries_list = []
for row in entries.find():
entries_list.append(row)
但是有更省力的寫法:
entries_list = [row for row in entries.find()]
贊!
參考 python 2.7.3 tutorial 文件:
5.1.4. List Comprehensions
較舊的文章
首頁
訂閱:
文章 (Atom)