如图
如何实现价格相加,计算价格总和


|
shakespacesDec 22, 2015
1
拼写不忍直视
|
|
mengzhuoDec 22, 2015
2
天啊……楼主你还是回去看看书吧
不……不是那本 Python 手册,我说的是英语书! |
|
3
……你想不想知道有個內置函式叫做 sum(*iterable)?
|
|
stillwaterDec 22, 2015
5
转换成 float 再相加吧
|
|
ericlsDec 23, 2015
6
@shakespaces 估计是手滑 uy 在 yt 旁边
|
|
7
让 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. |