
3条回答 默认 最新
shadowsland 2021-11-13 21:39关注#!/usr/bin/env python # -*- coding: utf-8 -*- num = input('输入金额,以¥或$开头加数字:') if num[0] not in ['$', '¥'] or not num[1:].isdigit(): # 错误判断 print('Input Error') else: currency = num[0] amount = float(num[1:]) if currency == '¥': print('¥%.2f = $%.2f' %(amount, amount/7.0)) else: print('$%.2f = ¥%.2f' %(amount, amount*7.0))本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报 编辑记录