[英]How to restart a python script using IDLE Basic
Hey Stackoverflow community, I'm quite new to coding but recently I have taken an interest in python. 嘿Stackoverflow社区,我对编码还很陌生,但是最近我对python产生了兴趣。 Below I have a sample script that's similiar to what I'm writing.
下面有一个示例脚本,与我正在编写的脚本类似。 I can't find anything basic so please keep it simple :D Also, how would I do this with multiple
if-elif-else
? 我找不到基本的东西,所以请保持简单:D另外,我将如何使用多个
if-elif-else
做到这一点?
print('Sample "Console" :D')
console = input('-> ')
if console == 'Restart':
print('Restarting')
If I want to have the code loop from the begining what do I do? 如果我想从一开始就进行代码循环,该怎么办? Please do a quick rewrite of the code with the loop.
请使用循环快速重写代码。
You can Use a while loop. 您可以使用while循环。
while True:
console = input('->')
if console != 'Restart' :
break
Hope it helps. 希望能帮助到你。 Happy Coding :)
快乐编码:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.