#要求在同一个文件夹下 就可以import #也可以保存在site-package下 import m1 m1.printdata("I am good")
import time as t #abbreviate as t print t.localtime() from time import time, localtime #only 2 function print localtime() #could write directly print time() from time import * #import all function, could type directly print time() ##26 build self block, script #create m1.py contain function 'printdata' #save it within same wd import m1 #could only call in within same wd m1.printdata('good') #or put m1.py into site-package folder ##27 continue break a = True while a: b = int(input('type something:')) if b == 1: a = False #這邊false以後 會印下面still在驗證whileloop在跳出到finish else: pass print 'still in whileloop' print 'finish' while True: b = int(input('type something:'))
import m1 # 凡在site-packages里面也可以 m1.printdata(123)
import m1 m1.printdata('Hello!')
import m1 calcul = m1.Calculator calcul.add(1, 2) #调用m1.py中类class的方法 m1.printdata("1234")