python实战计划 使用 find 函数

今天才发现sublime可以直接编译我我我……

highcharts

find({needName:needValue},{showType:showValue})

上次作业的清洗可以简化为

1
2
3
4
for i in item_info.
find({'pub_date':{'$in':['2016.01.12','2016.01.14']}),
{'area':{'$slice':2},'_id':0}:#id:notshow
print(i)

date

1
2
3
4
5
6
from datetime import date,timedelta
date(2016,02,02)
days = timedelta(days=1)
while the_date <= end_date:
yield (the_date.strftime('%Y.%m.%d'))
the_date = the_date + days

模板

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
options = {
'chart' : {'zoomType':'xy'},
'title' : {'text': 'Monthly Average Temperature'},
'subtitle': {'text': 'Source: WorldClimate.com'},
'xAxis' : {'categories': ['周一', '周二', '周三', '周四']},
'yAxis' : {'title': {'text': '数量'}}
}

series = [
{
'name': 'OS X',
'data': [11,2,3,4],
'type': 'line',
'y':5
}, {
'name': 'Ubuntu',
'data': [8,5,6,7],
'type': 'line',
'color':'#ff0066'
}, {
'name': 'Windows',
'data': [12,6,7,2],
'type': 'line'
}, {
'name': 'Others',
'data': [29,24,68,23],
'type': 'line'
}
]

charts.plot(series, options=options,show='inline')
# options=dict(title=dict(text='Charts are AWESOME!!!'))

#AIM

依旧用现成数据库数据吧..

Results

结果

Conclusion

yield 是一个类似 return 的关键字,只是这个函数返回的是个生成器。

datetime

文章目录
  1. 1. Results
  2. 2. Conclusion