python 系統學習例項1.2
阿新 • • 發佈:2018-12-11
# C = ( F - 32 ) / 1.8 # F = C * 1.8 + 32
def tempConvert(): t = input("請輸入數值:") R = ["RMB","rmb"] U = ["USD","usd"] if t[0:3] in R: temp = float(t[3:])/6.78 # print(temp) temp = "{:.2f}".format(temp) temp = "USD" + str(temp) print("結果:",temp) elif t[0:3] in U: temp = float(t[3:])*6.78 temp = "{:.2f}".format(temp) temp = "RMB" + str(temp) print("結果:",temp) else: print("輸入格式錯誤") return False return temp
tempConvert()