【问题标题】:statement that executing code over and over [duplicate]一遍又一遍地执行代码的语句[重复]
【发布时间】:2019-11-30 22:03:33
【问题描述】:

我不知道如何处理一遍又一遍地执行的代码。我想实现这样的目标: (代表输出)

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

【问题讨论】:

    标签: python if-statement


    【解决方案1】:

    你可以用

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

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

    【讨论】:

    • 当我输入它时,我输入的文本被一遍又一遍地写入。我希望能够提供一个输入然后下一个和下一个......但没有完成过程。
    【解决方案2】:

    你的意思是这样吗?

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

    【讨论】:

    • 谢谢你,真的很感激,我一个月不知道怎么做
    • @ApocalypseNow 您能否将此答案标记为正确?谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-16
    相关资源
    最近更新 更多