classInvoking.py
#coding=utf-8
class A(object):
def getMinimum(self,arr):
mini=arr[0]
for i in list(range(1,len(arr))):
if mini>arr[i]:
mini=arr[i]
return mini
#c=[3,4,6,7,1,3,5,7]
#a=A()
#mini=a.getMinimum(c)
#print(mini)
def getprint():
print("hello")
-----------------------------------------------------
callA.py #调用classInvoking.py中的类A。
#coding=utf-8
from classInvoking import A
def callA():
b=[4,5,6,7,3,2,8,4,]
a=A()
mini=a.getMinimum(b)
print(mini)
callA()
---------------------------------------------------------------
#coding=utf-8
from classInvoking import getprint #调用classInvoking.py中的getprint方法。
def callA():
b=[4,5,6,7,3,2,8,4,]
a=A()
mini=a.getMinimum(b)
print(mini)
getprint()
-----------------------------------------------------------------------
#coding=utf-8
import classInvoking as ci #导入整个包
def callA():
b=[4,5,6,7,3,2,8,4,]
a=A()
mini=a.getMinimum(b)
print(mini)
ci.getprint() #直接调用方法
d=[4,5,6,7,3,2,8,4]
a=ci.A()
m=a.getMinimum(d) #创建对象
print(m)