[英]Python | Stopping/Restarting a script after user_input
在我問這個問題之前,我想說我對Python還是很陌生,所以無論問什么都可能很容易做到。
我的問題是:回答此問題后,如何停止腳本。
s1 = input("Is your phone freezing/stuttering? ")
if s1 == "Yes" or s1 == "yes":
print("Try deleting some apps and this might help with your problem")
if s1 == "No" or s1 == "no":
def foo():
while True:
return False
所以我在這里想要的是,當用戶回答“是”時,我希望解決方案出現並且腳本停止,或者甚至重啟。
一個簡單的出口可能由此實現。
我還使用了較低的功能,因此它看起來會更pythonic
只需一個簡單的循環:
s1 = "yes"
while s1 == "yes":
s1 = input("Is your phone freezing/stuttering? ").lower()
祝好運 !
您可以做的是圍繞它創建一個循環
x = 4
while x == 4:
s1 = input("Is your phone freezing/stuttering? ")
if s1 == "Yes" or s1 == "yes":
print("Try deleting some apps and this might help with your problem")
if s1 == "No" or s1 == "no":
def foo():
while True:
return False
break #<-- only if you want the program to end after false#
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.