how to call a function in a class from main

我正在尝试从main..how中调用一个类定义的函数吗?

class file_process:
    def findb(self, id):
    ....  

def main():
  id = sys.argv[2]
 file_process.findb(id)//how to call findb function from main,this is giving an error

Since finddb is a method, you need to call it on an instance of file_process :

file_process().finddb(id)

I strongly urge you to study up on Python and classes, I can recommend the Python tutorial, before you continue.


您需要先创建一个类的实例:

process = file_process()
process.findb(id)
链接地址: http://www.djcxy.com/p/55150.html

上一篇: 对象没有属性

下一篇: 如何从main调用一个类的函数