當(dāng)前位置:首頁
> Pythonwhile循環(huán)一般比for循環(huán)慢嗎
Pythonwhile循環(huán)一般比for循環(huán)慢嗎(python for循環(huán)和while循環(huán)有什么區(qū)別)
這是兩重循環(huán),while里面執(zhí)行for循環(huán) for i in range1000sum+=i 執(zhí)行完成for后已經(jīng)從0加到 999了,然后再判斷sumlt500不成立,退出while循環(huán),和沒有while的結(jié)果一樣 sum=0 for i in range1000if sum+i=;dowhile循...