str(x) for x in range(1,int(nm))
mmpags = [new.url+'_'+str(x) for x in range(1,int(nm))+'.html']
TypeError: unsupported operand type(s) for +: 'range' and 'str' 求助 我这里写的哪里有问题 str(x) for x in range(1,int(nm)) 我这个应该怎么写 nm 是页面最大数 1 到 nm
1
mayne95 2017-05-30 09:48:28 +08:00 via Android
加 html 放到 str 后面
|
2
xiaoyu9527 OP |
3
mseasons 2017-05-30 09:51:49 +08:00
mmpags = [new.url+'_'+str(x)+'.html' for x in range(1,int(nm))]
|
4
katsusan 2017-05-30 09:53:04 +08:00
>>> newurl = 'v2ex.com'
>>> mmpages = [newurl + '_' + str(x) + '.html' for x in range(5)] >>> mmpages ['v2ex.com_0.html', 'v2ex.com_1.html', 'v2ex.com_2.html', 'v2ex.com_3.html', 'v2ex.com_4.html'] |
5
justtery 2017-05-30 09:55:48 +08:00 via Android
[new url+'_'+str(url)+'.html' for x in range (1, int(num))]
|
6
xiaoyu9527 OP 搞定了。 竟然后边是生成语句。
还有这种骚操作 |