zoukankan      html  css  js  c++  java
  • [解决方案] pythonchallenge level 4

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

    查看页面源代码或者点击图片

    http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=12345

    and the next nothing is 44827

    本题将页面中的数字代替url中nothing的值

    python:

    import re
    import requests
    burl='http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing='
    new=u'12345'
    res=re.compile(r'and the next nothing is (d+)')
    while 1:
      gurl=requests.get(burl+str(new))
      content=gurl.text
      print content
      try:
        value=re.findall(res,gurl.text)[0]
        new,old=value,new
      except:
        status=raw_input('continue or break(c/b):')
        if status=='c':
            rnew=raw_input('input the next nothing is number(default:%s/2)):' % new)
            if not rnew:
                new = int(new)/2
            else:
                new = int(rnew)
        else:
            break

    最后得到:peak.html

    http://www.pythonchallenge.com/pc/def/peak.html

  • 相关阅读:
    C# UDP实现通信的方法
    Leetcode 559. N叉树的最大深度
    101. 对称二叉树
    108. 将有序数组转换为二叉搜索树
    剑指 Offer 55
    Linux
    Linux
    Linux
    Linux
    Linux
  • 原文地址:https://www.cnblogs.com/hsp401/p/4483509.html
Copyright © 2011-2022 走看看