# -*- coding: utf-8 -*-
"""
Created on Tue Oct 23 20:56:51 2018
@author: lishuwei
"""
file名:li
import os
def li():
d=float(input('Please enter what is your initial balance: \n'))
p=float(input('Please input what is the interest rate (as a number): \n'))
d=float(d+d*(p/100))
year=1
while year<=5:
d=float(d+d*p/100)
print('Your new balance after year:',year,'is',d)
year=year+1
print('your final year is',d)
if __name__=="__main__":
print(os.getcwd())
优点:文件调用时候,可以不用执行 print(os.getcwd()),测试时可以用,调用的格式
import selffun
selffun.li()