【发布时间】:2020-10-21 21:05:39
【问题描述】:
我有一个带有 id 的列表(列表)。作为使用 wget 进行在线检查的结果,该列表的每个元素都会返回一个字符串“true”或“false”。 我想遍历该列表,只要有一个元素返回“假”值。 基本上我想重复一遍:
for i in range(len(list)):
wget online check
if status == 'true':
write id to another list
elif status == 'false':
continue
time.sleep()
一遍又一遍,直到一切都是真的。
我用嵌套的while循环尝试过:
for j in range(len(list)):
while status_ == 'false':
wget online check
if status == 'true':
write id to another list
elif status == 'false':
continue
time.sleep()
但这不起作用。 有人可以帮忙吗?
干杯
【问题讨论】:
-
status 总是一个字符串还是你可以把它变成一个布尔值?
-
它总是一个字符串。更具体地说:状态写入一个文件中,该文件在发送检查请求时下载。
标签: python loops if-statement while-loop