我想问一下如何在某些时候将True循环打破,然后重新启动它。
while True:
if a==0:
print "ok"
elif a==1:
break
#want to start over again
command = sock.recv(1024)
if blah blah ==blah:
.........
答案 0 :(得分:2)
您正在寻找的内容可能是continue
while True:
if a==0:
print "ok"
elif a==1:
continue
# goes back to top of loop
else:
print "ok"