未定义Python循环中的循环问题

2024-10-02 06:25:26 发布

您现在位置:Python中文网/ 问答频道 /正文

我的循环行不通

Loop = True

while loop:
    print ("hi")
#should constanly print hi

NameError:未定义名称“loop”


Tags: 名称looptruehiprint未定义shouldwhile
2条回答

问题是你把Loop(注大写L)和Loop(注非大写L)放在一起,这样应该可以:

Loop = True
while Loop:
    print ("hi")

你不需要在这里声明变量。你知道吗

while True:
    print("hi")

相关问题 更多 >

    热门问题