我不明白這個簡單的代碼:的Python:重試,直到一些變化
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import time
for val in "cacatcaca":
try:
if val == "c":
print(val)
time.sleep(0.5)
if val == "a":
print(val)
time.sleep(0.5)
except val == "t":
print('We are stock in the letter T')
time.sleep(0.5)
continue
它給我的結果:
而我想有是讓股票在't'
直到時間的盡頭:
c
a
c
a
We are stock in the letter T
We are stock in the letter T
We are stock in the letter T
...
...
...
我的目標是當我收到一個重用爲谷歌API代碼。
我想繼續下去,並嘗試JSON
響應,直到我得到不同的東西。