def main () import chap4func date = [ { "name" : "Yamamoto" , "bill" : "40000" , "crg" : True } , { "name" : "Yoshida" , "bill" : "25000" , "crg" : False } ] for rec in date : bill = rec [ "bill" ] if rec [ "crg" ] : bill chap4func.add_charge (bill) chap4func.create_mail ( rec[ "name" ] , bill ) if __name__ == ("__main__") : main ()
def main(): import chap4func chap4func.create_mail("Yamamoto", 40000)
# モジュール「chap4func」 # import chap4func # chap4func.create_mail('山本', 40000) import chap4func data = [ {'name':'山本', 'bill':40000, 'crg':True}, {'name':'吉田', 'bill':25000, 'crg':False} ] for rec in data: bill = rec['bill'] if rec['crg']: bill = chap4func.add_charge(bill) chap4func.create_mail(rec['name'],bill)
# -*- coding: UTF-8 #関数を組合わせて使ってみよう #関数をインポートする import chap4func chap4func.create_mail('山本', 40000)