Python Cha4

it2022-05-09  36

Cha4指的是从0开始,不是第4个,即第5个,今后不再解释。

这个简单,因为有这方面的经验,注意几点:

1. 中间会有混淆,不是所有的都是nothing is xxx,有的时候会有2个number.

2. 中间有个要把数除以一个2的操作.

3. 100多次,就能搞定.

第1点,用string的split,按is来分割,取最后的串,然后用正则表达式,提取出数字来。

第2点,手动处理一下就行。

然后就来到下一关了,恶心,没经验的,不会知道peak hell跟peakle发音类似,而peakle是python里的一个东东,下次继续学习~

代码如下:

#!/usr/bin/env python #coding=GB18030     import urllib2, re   oUrl = 'http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing='     f = open('d:\desktop\cha4_0.txt', 'w')   nothing = '46059' for i in range(400): url = oUrl + nothing req = urllib2.Request(url) res = urllib2.urlopen(req)   html = res.read() splitList = html.split('is')   nothing = re.search('[0-9]+', splitList[len(splitList) - 1]).group(0) f.write(nothing + '\n') print i + 198

转载于:https://www.cnblogs.com/litstrong/archive/2011/05/29/2062327.html

相关资源:python DataFrame 取差集实例

最新回复(0)