我有一个程序名称“new.py”,带有“:
class hello:
def __init__(self, summary):
self.summary = summary
def hi(self):
print self.summary
if __name__ == "__main__":
h = hello(summary = "this is a hello program")
h.hi()
当我想将函数 hi 访问到另一个程序名称 another.py 中时,我无法访问该函数.. 请帮助我并纠正我... another.py:
import new
class another:
def __init__(self, value):
self.value = value
def show(self):
print "value is %s" % self.value
new.hi()
print "done"
if __name__ == "__main__":
a = another(value = "this is a another value")
a.show()
输出:
new.hi()
AttributeError: 'module' object has no attribute hi