我正在尝试从 main 调用类中定义的函数。我该怎么做?
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
我正在尝试从 main 调用类中定义的函数。我该怎么做?
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
由于finddb是一种方法,因此您需要在以下实例上调用它file_process:
file_process().finddb(id)
我强烈建议您学习 Python 和课程,我可以推荐Python 教程,然后再继续。
您需要先创建一个类的实例:
process = file_process()
process.findb(id)