繁体   English   中英

一遍又一遍地执行代码的声明[重复]

[英]statement that executing code over and over [duplicate]

我不知道如何编写一遍又一遍执行的代码。 我想实现这样的事情:(<代表输入,>代表输出)

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

您可以通过

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

while 循环将继续执行直到条件变为假(在这种情况下它永远不会)所以如果/当你想跳出循环时你需要使用break语句

你是说这样吗?

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM