Commit 5b14b1b3 by 陈森彬

处理百分比带小数点的情况

parent 1fcdf57b
Showing with 5 additions and 1 deletions
......@@ -137,10 +137,14 @@ def unit_conversion(unit_res, kw):
unit_str = unit_str.replace("-","")
unit_num = int(kw.replace(unit_str, "").replace("-", ""))
else:
unit_num = int(kw.replace(unit_str, ""))
if "." in kw:
unit_num = float(kw.replace(unit_str, ""))
else:
unit_num = int(kw.replace(unit_str, ""))
true_unit = str(delete_extra_zero(unit_num * unit_data[unit_str]))
elif "." in kw: # 处理小数点
unit_num = float(kw.replace(unit_str, ""))
true_unit = str(delete_extra_zero(unit_num * unit_data[unit_str])) + unit_key
else:
unit_num = int(kw.replace(unit_str, ""))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment