-2
所以我有一個循環運行2次,但我有另一個循環內循環運行x次的時間。即使第一個循環完成循環,我也需要跟蹤循環內部計數,以便相應地更改代理。Python跟蹤循環之外的循環次數嗎?
proxyList=[proxy1,proxy2,proxy3,proxy4,proxy5]
#this will be done 2 times
for accts in acctPile:
with requests.Session() as s:
for loop,channel in enumerate(channelsss):
#changes proxies each 7th loop but restarts whenever loop is over :(
proxies = proxyList[loop // 7 % len(proxyList)]
我面臨的問題是當第一個循環完成循環內部循環計數重新啓動,因此它使用相同的代理。
如何使它從剩餘的位置開始計算,因此它不使用相同的代理?
使用itertools.cycle –