我试图创建一个依赖于findall结果的循环。我的循环每次需要一个文本来搜索模式,如果它发现它正在做一些工作人员。上一次搜索什么也没找到时,它给了我一个错误:
cursor = re.findall(r'MDpub\w+[^\"]', f)[0]
IndexError: list index out of range
我的python代码如下
cursor = re.findall(r'MDpub\w+[^\"]', f)[0]
while cursor:
next_url = 'url'
subId = subId+1
wget = "wget command"
os.system(wget)
f = open(('name of file')
if (re.findall(r'MDpub\w+[^\"]', f) != cursor):
cursor = re.findall(r'MDpub\w+[^\"]', f)[0]
print cursor
目前没有回答
相关问题 更多 >
编程相关推荐