TypeError: unbound method strftime() must be called with datetime instance as first argument (got str instance instead) at Form1, line 38
TypeError: unbound method strftime() must be called with datetime instance as first argument (got str instance instead) at Form1, line 38
我正在尝试让我的代码在 HH:MM:SS 内显示我的 "def timer_progress_tick(self, **event_args):" 而不是仅仅几秒钟。
https://docs.python.org/3/library/datetime.html - 查看 python 日期时间库。
from datetime import datetime
def timer_progress_tick(self, **event_args):
"""This method is called Every [interval] seconds. Does not trigger if
[interval] is 0."""
if self.start_time is not None:
self.label_time_elapsed.text = "{}".format(
datetime.strftime('%H:%M:%S', (datetime.now() - self.start_time))
)
我明白了;
TypeError: 未绑定方法 strftime() 必须以 datetime 实例作为第一个参数调用(取而代之的是 str 实例)
在 Form1,第 38 行
你用错了strftime
。它是对象的方法,不能从模块中调用。
self.label_time_elapsed.text = "{}".format(
(datetime.now() - self.start_time).strftime('%H:%M:%S'))
)
我正在尝试让我的代码在 HH:MM:SS 内显示我的 "def timer_progress_tick(self, **event_args):" 而不是仅仅几秒钟。
https://docs.python.org/3/library/datetime.html - 查看 python 日期时间库。
from datetime import datetime
def timer_progress_tick(self, **event_args):
"""This method is called Every [interval] seconds. Does not trigger if
[interval] is 0."""
if self.start_time is not None:
self.label_time_elapsed.text = "{}".format(
datetime.strftime('%H:%M:%S', (datetime.now() - self.start_time))
)
我明白了;
TypeError: 未绑定方法 strftime() 必须以 datetime 实例作为第一个参数调用(取而代之的是 str 实例) 在 Form1,第 38 行
你用错了strftime
。它是对象的方法,不能从模块中调用。
self.label_time_elapsed.text = "{}".format(
(datetime.now() - self.start_time).strftime('%H:%M:%S'))
)