无法在计划作业中调用方法

时间:2017-05-11 18:06:22

标签: python python-3.x schedule

我有一个看起来像这样的课程:

class Account(object):
    """A simple bank account"""

    def __init__(self, balance=0.0):
        """
        Return an account object with a starting balance of *balance*.
        """
        self.balance = balance

    def withdraw(self, amount):
        """
        Return the balance remaining after withdrawing *amount* dollars.
        """
        self.balance -= amount
        return self.balance

    def deposit(self, amount):
        """
        Return the amount remaining after depositing *amount* dollars.
        """
        self.balance += amount
        return self.balance

我会在xyz中初始化它:

xyz = Account(balance=6000)
xyz.balance
> 6000

我也有一个愚蠢的打印功能:

def thing():
    print("I am doing a thing...")

当我尝试在deposit流程中调用schedule方法时:

import schedule

# this works
# schedule.every(5).seconds.do(thing)

# this doesn't work
schedule.every(5).seconds.do(xyz.deposit(2300))

while True:
    schedule.run_pending()

我收到以下错误:

  

TypeError:第一个参数必须是可调用的

有什么想法吗?甚至可以在计划流程中调用方法吗?

0 个答案:

没有答案