自制体重转换器

自定制体重转换器,用户可能输出g、jin、mg,统一输出为kg。

tz = input("请输入体重:")
if (tz[-2:-1]) == 'm' and (tz[-1:]) == 'g':
    weight = eval(tz[:-2])/1000000
    print(str(weight)+'kg')
elif (tz[-3:]) == 'jin':
    weight = eval(tz[:-3])/2
    print(str(weight)+'kg')
elif (tz[-1:]) == 'g':
    weight = eval(tz[:-1])/1000
    print(str(weight)+'kg')
else:
    print("输入格式有误!")
posted @ 2019-07-12 20:13  PLPLPL  阅读(533)  评论(0编辑  收藏  举报
// 目录