From a23f2c998944c8681b9fb3e02245b61174497b19 Mon Sep 17 00:00:00 2001 From: usami Date: Fri, 14 Mar 2025 11:04:27 +0800 Subject: [PATCH] fix error due to not process issues with temp detect --- work.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/work.py b/work.py index 93b75a2..46b6674 100644 --- a/work.py +++ b/work.py @@ -30,10 +30,14 @@ isCelsius = False if str(temp).__contains__("C"): isCelsius = True -temp = float(temp.replace("C", "")) +if isCelsius: + temp = float(temp.replace("C", "")) +else: + temp = float(temp.replace("F", "")) + #转换成华氏度 -if (isCelsius): +if isCelsius: print("Fahrenheit should be " + str(temp * 1.8 + 32)) else: print("Celsius should be " + str((temp - 32) / 1.8) )