Python挑战游戏( PythonChallenge)闯关之路Level 0

来源:互联网 发布:淘宝运营公开课 编辑:程序博客网 时间:2024/06/13 11:08

关卡入口地址:http://www.pythonchallenge.com/pc/def/0.html


打开这个页面之后如下:



根据上面的提示,就是说把图画上内容的结果,计算出来,转换为url就OK了


为了练习呢,这一关,虽然简单, 但是还是用程序写一下把

#coding:utf-8import urllib2class PythonChallege:def level0(self):url_level_0='http://www.pythonchallenge.com/pc/def/0.html'#第0关的网址next_level_tips=str(2**38)#提示信息be_replace_str=url_level_0.split('/')[-1].split('.')[0]#要被替换的内容print be_replace_str+" will be replace"next_level_url=url_level_0.replace(be_replace_str,next_level_tips)#下一关网址print 'next level url is :'+next_level_urlif urllib2.urlopen(next_level_url).code == 200:print 'get right url'mychallenge=PythonChallege()mychallenge.level0()


结果如下:


0 will be replacenext level url is :http://www.pythonchallenge.com/pc/def/274877906944.htmlget right url



0 0
原创粉丝点击