Ray's playground

 

Python Challenge 4

http://www.pythonchallenge.com/pc/def/linkedlist.php

code
 1 >>> import re, urllib, string
 2 >>> url = 'http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing='
 3 >>> nothing = '12345'
 4 >>> while(True):
 5     data = urllib.urlopen(url + nothing).read()
 6     print data
 7     r = re.compile('\d+')
 8     match = r.findall(data)
 9     if len(match) == 1:
10         nothing = str(match[0])
11     elif len(match) == 2:
12         nothing = str(match[1])
13     elif data.find('Yes'!= -1:
14         nothing = str(string.atoi(nothing) / 2)
15     else:
16         break
17 # peak.html

 

 

posted on 2010-08-12 20:14  Ray Z  阅读(223)  评论(0编辑  收藏  举报

导航