标签:enter sys print int pat user NPU ase write
import os,sys
base_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
sys.path.append(base_dir)
print (sys.path)
print(
‘ICBC Bank‘.center( 30,‘-‘),‘\n‘
‘1.账户信息‘‘\n‘
‘2.转账‘
)
alex_money = {‘user‘:‘alex‘,}
def choice(num):
if num == ‘1‘:
f = open(‘../account/alex.json‘,‘r‘)
print (type(f.read()))
elif num == ‘2‘:
f = open(‘../account/alex.json‘,‘r‘)
f2 = open(‘../account/tesla_company.json‘,‘r‘)
alex_act = int(float(f.read().strip()))-950000*(1+0.05)
tesla_act = int(float(f2.read().strip()))+950000*(1+0.05)
f.close()
f2.close()
f = open(‘../account/alex.json‘,‘w‘)
f2 = open(‘../account/tesla_company.json‘,‘w‘)
f.write(str(int(alex_act)))
f2.write(str(int(tesla_act)))
choice1 = input(‘选择服务:‘)
choice(choice1)
最近alex买了个Tesla Model S,通过转账的形式,并且支付了5%的手续费,tesla价格为95万。账户文件为json,请用程序实现该转账行为。
标签:enter sys print int pat user NPU ase write
原文地址:https://www.cnblogs.com/fxm12138/p/12115479.html