反复执行代码的语句

2024-05-15 00:19:24 发布

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

我不知道如何去做一遍又一遍执行的代码。我想实现这样的目标: (<;表示输入,>;表示输出)

message=input()
print('Write down the text.')
>Write down the text.
<qwerty
>qwerty
>Write down the text.
<asd
>asd

Tags: the代码textltgtmessage目标input
2条回答

你是说像这样吗

while True:
   message=input("Write down the text: ")
   print(message)

你可以通过

   while True:
      // code you want to execute repeatedly here

while循环将继续执行,直到条件变为false(在本例中,它永远不会这样做),因此如果/当您想要中断循环时,需要使用break语句

相关问题 更多 >

    热门问题