1
shakespaces 2015-12-22 21:24:28 +08:00
拼写不忍直视
|
2
mengzhuo 2015-12-22 21:32:30 +08:00
天啊……楼主你还是回去看看书吧
不……不是那本 Python 手册,我说的是英语书! |
3
Arthur2e5 2015-12-22 21:46:40 +08:00 1
……你想不想知道有個內置函式叫做 sum(*iterable)?
|
5
stillwater 2015-12-22 23:09:52 +08:00
转换成 float 再相加吧
|
6
ericls 2015-12-23 00:15:21 +08:00
@shakespaces 估计是手滑 uy 在 yt 旁边
|
7
latyas 2015-12-23 03:52:37 +08:00 2
让 lz 难受一下
sum(map(lambda item: float(re.findall('[\d\.]+', item)[0]), map(lambda x: x.text, i.select['.price_n']))) @Arthur2e5 是 sum(iterable) sum(iterable, start=0, /) Return the sum of a 'start' value (default: 0) plus an iterable of numbers When the iterable is empty, return the start value. This function is intended specifically for use with numeric values and may reject non-numeric types. |