我希望用户为一个程序提供输入,这样如果用户输入错误,代码就会提示他们输入正确的值。你知道吗
我尝试了这段代码,但由于continue
语句,它从一开始就运行循环。我希望代码返回到其各自的try块。请帮忙。你知道吗
def boiler():
while True:
try:
capacity =float(input("Capacity of Boiler:"))
except:
print ("Enter correct value!!")
continue
try:
steam_temp =float(input("Operating Steam Temperature:"))
except:
print ("Enter correct value!!")
continue
try:
steam_pre =float(input("Operating Steam Pressure:"))
except:
print ("Enter correct value!!")
continue
try:
enthalpy =float(input("Enthalpy:"))
except:
print ("Enter correct value!!")
continue
else:
break
boiler()
这是你想要的吗?你知道吗
示例运行
相关问题 更多 >
编程相关推荐