[2.5.1]构建循环有一些例外吗? [英] [2.5.1] Building loop with some exceptions?
问题描述
你好
我需要通过一个从01开始到99结束的循环来调用URL,
但是必须忽略一些步骤:
=====
url =" http://www.acme.com/list?code ="
p = re.compile(" ^(\d +)\ t(。+)$")
,i = 01到99,除了04,34 ,40,44,48,54,57,67,76,83,89:
f = urllib.urlopen(url + i)
page = f.read( )
f.close()
for page in page:
m = p.search(line)
如果m:
code = m.group(1)
label = m.group(2)
print" Code =" +代码+ #Label =" +标签
=====
我对Python的方法很无能为力: - /
感谢您的帮助。
Hello
I need to call a URL through a loop that starts at 01 and ends at 99,
but some of the steps must be ignored:
=====
url = "http://www.acme.com/list?code="
p = re.compile("^(\d+)\t(.+)$")
for i=01 to 99 except 04, 34, 40, 44, 48, 54, 57, 67, 76, 83, 89:
f = urllib.urlopen(url + i)
page = f.read()
f.close()
for line in page:
m = p.search(line)
if m:
code = m.group(1)
label = m.group(2)
print "Code=" + code + " # Label=" + label
=====
I''m clueless at what the Python way is to do this :-/
Thank you for any help.
推荐答案
")
for i = 01到99除了04,34,40,44,48,54,57,67,76,83,89:
f = urllib.urlopen(url + i)
page = f.read()
f.close()
for page in page:
m = p。搜索(行)
如果m:
code = m.group(1)
label = m.group(2)
print" Code =" +代码+ #Label =" +标签
=====
我对Python的方法很无能为力: - /
感谢您的帮助。
")
for i=01 to 99 except 04, 34, 40, 44, 48, 54, 57, 67, 76, 83, 89:
f = urllib.urlopen(url + i)
page = f.read()
f.close()
for line in page:
m = p.search(line)
if m:
code = m.group(1)
label = m.group(2)
print "Code=" + code + " # Label=" + label
=====
I''m clueless at what the Python way is to do this :-/
Thank you for any help.
11月4日,1:20 * pm,Gilles Ganault< nos ... @ nospam.comwrote:
On Nov 4, 1:20*pm, Gilles Ganault <nos...@nospam.comwrote:
你好
我需要通过一个从01开始到99结束的循环调用一个URL,
但必须忽略一些步骤:
=====
url =" http://www.acme .com / list?code ="
p = re.compile(" ^(\d +)\t(。+)
Hello
I need to call a URL through a loop that starts at 01 and ends at 99,
but some of the steps must be ignored:
=====
url = "http://www.acme.com/list?code="
p = re.compile("^(\d+)\t(.+)
" )
for i = 01到99除了04,34,40,44,48,54,57,67,76,83,89:
")
for i=01 to 99 except 04, 34, 40, 44, 48, 54, 57, 67, 76, 83, 89:
排序(列表(设置(域) - 设置(例外)))
设置减法。
sorted( list( set( domain ) - set( exceptions ) ) )
Set subtraction.
这篇关于[2.5.1]构建循环有一些例外吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!