当前位置: 代码迷 >> 综合 >> python2-温度转换、货币转换
  详细解决方案

python2-温度转换、货币转换

热度:69   发布时间:2023-12-03 12:40:57.0
# 温度转换
Temper = input("")
if Temper[-1] in ['F','f']:C = (eval(Temper[0:-1])-32)/1.8print("{:.2f}C".format(C))
elif Temper[-1] in ['C','c']:F = 1.8*eval(Temper[0:-1])+32 print("{:.2f}F".format(F))
else:print("输入格式错误")Template = "零一二三四五六七八九十"
n = input()
for i in n:print(Template[eval(i)],end='')#货币转换
Money = input("")
if Money[:3] in ["RMB"]:USD = eval(Money[3:])/6.78print("USD{:.2f}".format(USD))
elif Money[:3] in ["USD"]:RMB = eval(Money[3:])*6.78print("RMB{:.2f}".format(RMB))
else:print()CurStr = input()
if CurStr[:3] == "RMB":print("USD{:.2f}".format(eval(CurStr[3:])/6.78))
elif CurStr[:3] in ['USD']:print("RMB{:.2f}".format(eval(CurStr[3:])*6.78)