[英]I'm having trouble with turtle
當我運行代碼時,烏龜窗口打開,然后什么也沒有發生。 幾秒鍾后,我的光標變成了正在加載的光標,我被迫殺死了該程序。 我的代碼在這里怎么了?
import turtle
import random
turtle.speed(10)
for x in range(1,100):
y=random.randint(000000,999999)
y=str(y)
while not len(y)==0:
y="0"+y
y="#"+y
turtle.color(y)
turtle.circle(40+x)
您的程序中無休止的循環
import turtle
import random
turtle.speed(10)
for x in range(1,100):
y=random.randint(000000,999999)
y=str(y)
print(1)
while len(y)<6: # was always true: not len(y)==0
print(3) # would print a lot of 3
y="0"+y
y="#"+y
print(2)
turtle.color(y)
turtle.circle(40+x)
如果發生此類情況,建議將打印語句添加到程序中。 然后,您可以跟蹤它的掛起位置。 另外,使用調試器可以幫助您發現問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.