account = {
"科目代码": 1001,
"科目名称": "银行存款",
"期初数": 150000,
"借方": 30000,
"贷方": 15000
}
account["贷方"] = 5000
num = account["期初数"] + account["借方"] - account["贷方"]
account["期末数"] = num
print(account)
account={'科目':1001,
'代码科目名称':'银行存款',
'期初数':150000,'借方':30000,
'贷方':10000}
account['贷方']=5000
account['期末数']=account['期初数']+account['借方']-account['贷方']
print(account)
输出:
{'科目': 1001, '代码科目名称': '银行存款', '期初数': 150000, '借方': 30000, '贷方': 5000, '期末数': 175000}
# -*- coding:utf-8 -*-
account = {
"科目代码":1001,
"科目名称":"银行存款",
"期初数":150000,
"借方":30000,
"贷方":10000,
}
print(' 原始字典 '.center(40,'='))
print(account)
#修改贷方金额
account['贷方'] = 5000
#字典中增加"期末数"的key
account['期末数'] = account['期初数'] + account['借方'] - account['贷方']
print(' 修改后的字典 '.center(40,'='))
print(account)