python 系统学习实例1.2 - 人民币与美元的转换

# RMB= USD  / 6.78‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‫‬
# USD = RMB* 6.78

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()

猜你喜欢

转载自blog.csdn.net/weixin_39241397/article/details/82828058