编程谜题-4

Posted on 2008-05-09 14:32 罗明 阅读(79) 评论(0)  编辑  收藏 所属分类: StudyPython
Follow the URL chain to get the result (the chain may contain over 300 URLs......)

谜题详细描述:http://www.pythonchallenge.com/pc/def/linkedlist.php

Python解决方案:
import urllib

nothing 
= "12345"
ii 
= 1
while ii<401:
  source 
= urllib.urlopen("http://www.pythonchallenge.com" 
    
+ "/pc/def/linkedlist.php?nothing="+nothing).read()
  nothing
=filter(str.isdigit, source)

  
print nothing
  
if source != "and the next nothing is " + nothing:
    
print "source is not: and the next nothing is " + nothing
    
print "source is: " + source
    nothing 
= raw_input("select which number?")
    
print "you set " + nothing + " as nothing"
  ii
+=1




版权所有 罗明

标题  
姓名  
主页
验证码 *  
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交