python if __name__=="__main__":
阿新 • • 發佈:2018-12-17
# -*- 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()