陪伴而非守候
def change(amount, bills): money = {} for bill in bills: bill_count = amount/bill money[bill] = bill_count amount -= bill * bill_count return moneyresult = change(87, [20, 5, 1])for coin, amount in result.items(): if amount != 0: print("%d X %d" % (amount, coin))将得到所需的结果。